diff --git a/README.md b/README.md
index 80d89b36..743cba7a 100644
--- a/README.md
+++ b/README.md
@@ -11,17 +11,12 @@
-
-
-
-
-
-
+
[telegram-news-badge]: https://img.shields.io/badge/Sophia%20News-Telegram-blue?style=flat&logo=Telegram
[telegram-news]: https://t.me/sophianews
@@ -34,6 +29,7 @@
[discord-news-badge]: https://discordapp.com/api/guilds/1006179075263561779/widget.png?style=shield
[discord-link]: https://discord.gg/sSryhaEv79
[![Discord][discord-news-badge]][discord-link]
+
diff --git a/README_de-de.md b/README_de-de.md
index 3a62a688..34d32235 100644
--- a/README_de-de.md
+++ b/README_de-de.md
@@ -11,17 +11,12 @@
-
-
-
-
-
-
+
[telegram-news-badge]: https://img.shields.io/badge/Sophia%20News-Telegram-blue?style=flat&logo=Telegram
[telegram-news]: https://t.me/sophianews
@@ -34,6 +29,7 @@
[discord-news-badge]: https://discordapp.com/api/guilds/1006179075263561779/widget.png?style=shield
[discord-link]: https://discord.gg/sSryhaEv79
[![Discord][discord-news-badge]][discord-link]
+
diff --git a/README_uk-ua.md b/README_uk-ua.md
index e4591a9b..dc48440e 100644
--- a/README_uk-ua.md
+++ b/README_uk-ua.md
@@ -11,17 +11,12 @@
-
-
-
-
-
-
+
[telegram-news-badge]: https://img.shields.io/badge/Sophia%20News-Telegram-blue?style=flat&logo=Telegram
[telegram-news]: https://t.me/sophianews
@@ -34,6 +29,7 @@
[discord-news-badge]: https://discordapp.com/api/guilds/1006179075263561779/widget.png?style=shield
[discord-link]: https://discord.gg/sSryhaEv79
[![Discord][discord-news-badge]][discord-link]
+
diff --git a/Wrapper/Config/config_Windows_10.json b/Wrapper/Config/config_Windows_10.json
index 4837e4f7..487ed023 100644
--- a/Wrapper/Config/config_Windows_10.json
+++ b/Wrapper/Config/config_Windows_10.json
@@ -1058,22 +1058,6 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
- {
- "Region": "System",
- "Control": "cmb",
- "Required": "false",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive"
- },
- "One": {
- "Tag": "Default"
- }
- },
- "Preset": "Zero",
- "WindowsDefault": "One"
- },
{
"Region": "System",
"Control": "cmb",
@@ -1824,19 +1808,6 @@
"Preset": "",
"WindowsDefault": ""
},
- {
- "Region": "UWP apps",
- "Control": "chk",
- "Required": "false",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": ""
- }
- },
- "Preset": "",
- "WindowsDefault": ""
- },
{
"Region": "UWP apps",
"Control": "cmb",
diff --git a/Wrapper/Config/config_Windows_10_LTSC.json b/Wrapper/Config/config_Windows_10_LTSC.json
index 9e7209a2..f4b3b62e 100644
--- a/Wrapper/Config/config_Windows_10_LTSC.json
+++ b/Wrapper/Config/config_Windows_10_LTSC.json
@@ -932,24 +932,6 @@
"LTSC2019": "true",
"LTSC2021": "true"
},
- {
- "Region": "System",
- "Control": "cmb",
- "Required": "false",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive"
- },
- "One": {
- "Tag": "Default"
- }
- },
- "Preset": "Zero",
- "WindowsDefault": "One",
- "LTSC2019": "true",
- "LTSC2021": "true"
- },
{
"Region": "System",
"Control": "cmb",
diff --git a/Wrapper/Config/config_Windows_11.json b/Wrapper/Config/config_Windows_11.json
index bb700c6f..16608a58 100644
--- a/Wrapper/Config/config_Windows_11.json
+++ b/Wrapper/Config/config_Windows_11.json
@@ -981,22 +981,6 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
- {
- "Region": "System",
- "Control": "cmb",
- "Required": "false",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive"
- },
- "One": {
- "Tag": "Default"
- }
- },
- "Preset": "Zero",
- "WindowsDefault": "One"
- },
{
"Region": "System",
"Control": "cmb",
@@ -1705,19 +1689,6 @@
"Preset": "",
"WindowsDefault": ""
},
- {
- "Region": "UWP apps",
- "Control": "chk",
- "Required": "false",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": ""
- }
- },
- "Preset": "",
- "WindowsDefault": ""
- },
{
"Region": "UWP apps",
"Control": "cmb",
diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json b/Wrapper/Localizations/de-DE/tooltip_Windows_10.json
index bc9a6e69..3005c460 100644
--- a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json
+++ b/Wrapper/Localizations/de-DE/tooltip_Windows_10.json
@@ -928,20 +928,6 @@
}
}
},
- {
- "Region": "System",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive",
- "ToolTip": "Setzt den Pfad der Umgebungsvariablen %TEMP% auf %SystemDrive%\\Temp."
- },
- "One": {
- "Tag": "Default",
- "ToolTip": "Setzt den Pfad der Umgebungsvariablen %TEMP% auf %LOCALAPPDATA%\\Temp (Standardeinstellung)."
- }
- }
- },
{
"Region": "System",
"Function": "Win32LongPathLimit",
@@ -1604,16 +1590,6 @@
}
}
},
- {
- "Region": "UWP apps",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": "",
- "ToolTip": "Standard-UWP-Apps mithilfe des Popup-Dialogfelds wieder herstellen. UWP-Apps können nur wiederhergestellt werden, wenn sie nur für den aktuellen Benutzer deinstalliert wurden."
- }
- }
- },
{
"Region": "UWP apps",
"Function": "HEVC",
diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json
index 146c8fff..6e15474b 100644
--- a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json
+++ b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json
@@ -862,20 +862,6 @@
}
}
},
- {
- "Region": "System",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive",
- "ToolTip": "Setzt den Pfad der Umgebungsvariablen %TEMP% auf %SystemDrive%\\Temp."
- },
- "One": {
- "Tag": "Default",
- "ToolTip": "Setzt den Pfad der Umgebungsvariablen %TEMP% auf %LOCALAPPDATA%\\Temp (Standardeinstellung)."
- }
- }
- },
{
"Region": "System",
"Function": "Win32LongPathLimit",
@@ -1503,16 +1489,6 @@
}
}
},
- {
- "Region": "UWP apps",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": "",
- "ToolTip": "Standard-UWP-Apps mithilfe des Popup-Dialogfelds wieder herstellen. UWP-Apps können nur wiederhergestellt werden, wenn sie nur für den aktuellen Benutzer deinstalliert wurden."
- }
- }
- },
{
"Region": "UWP apps",
"Function": "CortanaAutostart",
diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_10.json b/Wrapper/Localizations/en-US/tooltip_Windows_10.json
index 79d30c24..6e0a8c0f 100644
--- a/Wrapper/Localizations/en-US/tooltip_Windows_10.json
+++ b/Wrapper/Localizations/en-US/tooltip_Windows_10.json
@@ -928,20 +928,6 @@
}
}
},
- {
- "Region": "System",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive",
- "ToolTip": "Change the %TEMP% environment variable path to %SystemDrive%\\Temp."
- },
- "One": {
- "Tag": "Default",
- "ToolTip": "Change %TEMP% environment variable path to %LOCALAPPDATA%\\Temp (default value)."
- }
- }
- },
{
"Region": "System",
"Function": "Win32LongPathLimit",
@@ -1604,16 +1590,6 @@
}
}
},
- {
- "Region": "UWP apps",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": "",
- "ToolTip": "Restore the default UWP apps using the pop-up dialog box. UWP apps can be restored only if they were uninstalled only for the current user."
- }
- }
- },
{
"Region": "UWP apps",
"Function": "HEVC",
diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_11.json b/Wrapper/Localizations/en-US/tooltip_Windows_11.json
index 70ee781b..649ae90c 100644
--- a/Wrapper/Localizations/en-US/tooltip_Windows_11.json
+++ b/Wrapper/Localizations/en-US/tooltip_Windows_11.json
@@ -862,20 +862,6 @@
}
}
},
- {
- "Region": "System",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive",
- "ToolTip": "Change the %TEMP% environment variable path to %SystemDrive%\\Temp."
- },
- "One": {
- "Tag": "Default",
- "ToolTip": "Change %TEMP% environment variable path to %LOCALAPPDATA%\\Temp (default value)."
- }
- }
- },
{
"Region": "System",
"Function": "Win32LongPathLimit",
@@ -1503,16 +1489,6 @@
}
}
},
- {
- "Region": "UWP apps",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": "",
- "ToolTip": "Restore the default UWP apps using the pop-up dialog box. UWP apps can be restored only if they were uninstalled only for the current user."
- }
- }
- },
{
"Region": "UWP apps",
"Function": "CortanaAutostart",
diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json
index fa0b9fd2..a23659c5 100644
--- a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json
+++ b/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json
@@ -928,20 +928,6 @@
}
}
},
- {
- "Region": "System",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive",
- "ToolTip": "Изменить путь переменной среды для %TEMP% на %SystemDrive%\\Temp."
- },
- "One": {
- "Tag": "Default",
- "ToolTip": "Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\\Temp (значение по умолчанию)."
- }
- }
- },
{
"Region": "System",
"Function": "Win32LongPathLimit",
@@ -1604,16 +1590,6 @@
}
}
},
- {
- "Region": "UWP apps",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": "",
- "ToolTip": "Восстановить стандартные UWP-приложения, используя всплывающее диалоговое окно. UWP-приложения могут быть восстановлены, только если они были удалены для текущего пользователя."
- }
- }
- },
{
"Region": "UWP apps",
"Function": "HEVC",
diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
index 91d36dba..248c4cfb 100644
--- a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
+++ b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
@@ -862,20 +862,6 @@
}
}
},
- {
- "Region": "System",
- "Function": "TempFolder",
- "Arg": {
- "Zero": {
- "Tag": "SystemDrive",
- "ToolTip": "Изменить путь переменной среды для %TEMP% на %SystemDrive%\\Temp."
- },
- "One": {
- "Tag": "Default",
- "ToolTip": "Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\\Temp (значение по умолчанию)."
- }
- }
- },
{
"Region": "System",
"Function": "Win32LongPathLimit",
@@ -1503,16 +1489,6 @@
}
}
},
- {
- "Region": "UWP apps",
- "Function": "RestoreUWPApps",
- "Arg": {
- "Zero": {
- "Tag": "",
- "ToolTip": "Восстановить стандартные UWP-приложения, используя всплывающее диалоговое окно. UWP-приложения могут быть восстановлены, только если они были удалены для текущего пользователя."
- }
- }
- },
{
"Region": "UWP apps",
"Function": "CortanaAutostart",
diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
index 5973fe16..1ce3bfc0 100644
--- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
+++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
@@ -225,8 +225,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
"Ghost Toolbox" = "$env:SystemRoot\System32\migwiz\dlmanifests\run.ghost.cmd"
# https://win10tweaker.ru
"Win 10 Tweaker" = "HKCU:\Software\Win 10 Tweaker"
- # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
- "Modern Tweaker" = "Registry::HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\Modern Cleaner"
# https://boosterx.ru
BoosterX = "$env:ProgramFiles\GameModeX\GameModeX.exe"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=400#11
@@ -247,6 +245,8 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
WinClean = "$env:ProgramFiles\WinClean Plus Apps"
# https://github.com/Atlas-OS/Atlas
AtlasOS = "$env:SystemRoot\AtlasModules"
+ # https://www.gearupbooster.com
+ "GearUP Booster" = "${env:ProgramFiles(x86)}\GearUPBooster"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -280,13 +280,15 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Check whether Windows was broken by 3rd party harmful tweakers and trojans
$Tweakers = @{
# https://forum.ru-board.com/topic.cgi?forum=62&topic=30617&start=1600#14
- AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
+ AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
# Flibustier custom Windows image
- Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
+ Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
# https://github.com/hellzerg/optimizer
- Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
+ Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
# https://github.com/builtbybel/Winpilot
- Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
+ "Modern Tweaker" = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Modern Tweaker`"})"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -1920,7 +1922,7 @@ function AdvertisingID
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
@@ -5121,10 +5123,6 @@ function OneDrive
[switch]
$Install,
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Install"
- )]
[switch]
$AllUsers
)
@@ -5294,11 +5292,11 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
}
}
else
@@ -5333,7 +5331,7 @@ public static bool MarkFileDelete (string sourcefile)
# Remove invalid chars
[xml]$OneDriveXML = $Content -replace "", ""
- $OneDriveURL = ($OneDriveXML).root.update.amd64binary.url | Select-Object -Index 1
+ $OneDriveURL = $OneDriveXML.root.update.amd64binary.url | Select-Object -Index 1
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $OneDriveURL
@@ -5346,7 +5344,7 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
@@ -5605,296 +5603,6 @@ function Hibernation
}
}
-<#
- .SYNOPSIS
- The %TEMP% environment variable path
-
- .PARAMETER SystemDrive
- Change the %TEMP% environment variable path to %SystemDrive%\Temp
-
- .PARAMETER Default
- Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
-
- .EXAMPLE
- TempFolder -SystemDrive
-
- .EXAMPLE
- TempFolder -Default
-
- .NOTES
- Machine-wide
-#>
-function TempFolder
-{
- param
- (
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "SystemDrive"
- )]
- [switch]
- $SystemDrive,
-
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Default"
- )]
- [switch]
- $Default
- )
-
- switch ($PSCmdlet.ParameterSetName)
- {
- "SystemDrive"
- {
- if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:SystemDrive\Temp))
- {
- New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
- }
-
- # Cleaning up folders
- Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore
- Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # If there are some files or folders left in %LOCALAPPDATA\Temp%
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- $SymbolicLinkTask = @"
-Get-ChildItem -Path `$env:LOCALAPPDATA\Temp -Recurse -Force | Remove-Item -Recurse -Force
-
-Get-Item -Path `$env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {`$_.LinkType -ne """SymbolicLink"""} | Remove-Item -Recurse -Force
-New-Item -Path `$env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value `$env:SystemDrive\Temp -Force
-
-Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SymbolicLinkTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "SymbolicLink"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
- else
- {
- # Create a symbolic link to the %SystemDrive%\Temp folder
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- # The additional registry key creating are needed to fix the property type of the keys: SetEnvironmentVariable creates them with the "String" type instead of "ExpandString" as by default
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
- }
- "Default"
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- # Remove a symbolic link to the %SystemDrive%\Temp folder
- if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
- {
- (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete()
- }
-
- if (-not (Test-Path -Path $env:SystemRoot\Temp))
- {
- New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force
- }
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # Removing folders
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Ignore
-
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- $TempFolder = (Get-Item -Path $env:TEMP).FullName
- $TempFolderCleanupTask = @"
-Remove-Item -Path "$TempFolder" -Recurse -Force
-Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to clean up the temporary folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempFolderCleanupTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "TemporaryTask"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- }
- }
-}
-
<#
.SYNOPSIS
The Windows 260 character path limit
@@ -8360,6 +8068,24 @@ function RecommendedTroubleshooting
New-Item -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 3 -Force
+
+ # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
+ if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
+ {
+ New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
+ }
+ New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
+
+ Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 3
+
+ # Turn on Windows Error Reporting
+ Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
+ Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
+
+ Get-Service -Name WerSvc | Set-Service -StartupType Manual
+ Get-Service -Name WerSvc | Start-Service
}
"Default"
{
@@ -8370,24 +8096,6 @@ function RecommendedTroubleshooting
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 2 -Force
}
}
-
- # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
- if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
- {
- New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
- }
- New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
-
- Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1
-
- # Turn on Windows Error Reporting
- Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
- Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
-
- Get-Service -Name WerSvc | Set-Service -StartupType Manual
- Get-Service -Name WerSvc | Start-Service
}
<#
@@ -10849,7 +10557,7 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
- (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
+ $Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Alias" = $_.Name
@@ -11833,316 +11541,6 @@ function UninstallUWPApps
}
}
-<#
- .SYNOPSIS
- Restore the default UWP apps
-
- .EXAMPLE
- RestoreUWPAppsUWPApps
-
- .NOTES
- UWP apps can be restored only if they were uninstalled for the current user
-
- .NOTES
- Current user
-#>
-function RestoreUWPApps
-{
- Add-Type -AssemblyName PresentationCore, PresentationFramework
-
- #region Variables
- #region XAML Markup
- # The section defines the design of the upcoming dialog box
- [xml]$XAML = @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-"@
- #endregion XAML Markup
-
- $Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $XAML))
- $XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
- Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)
- }
-
- $Window.Title = $Localization.UWPAppsTitle
- $ButtonRestore.Content = $Localization.Restore
- # Extract the localized "Select all" string from shell32.dll
- $TextBlockSelectAll.Text = [WinAPI.GetStrings]::GetString(31276)
-
- $ButtonRestore.Add_Click({ButtonRestoreClick})
- $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
- #endregion Variables
-
- #region Functions
- function Get-AppxManifest
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- # You cannot retrieve packages using -PackageTypeFilter Bundle, otherwise you won't get the InstallLocation attribute. It can be retrieved only by comparing with $Bundles
- $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
- $AppxPackages = @(Get-AppxPackage -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Where-Object -FilterScript {$_.Name -in $Bundles})
-
- # The Bundle packages contains no Microsoft Teams
- if (Get-AppxPackage -Name MSTeams -AllUsers)
- {
- $AppxPackages += Get-AppxPackage -Name MSTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"}
- }
-
- $PackagesIds = [Windows.Management.Deployment.PackageManager, Windows.Web, ContentType = WindowsRuntime]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName
-
- foreach ($AppxPackage in $AppxPackages)
- {
- $PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name}
-
- if (-not $PackageId)
- {
- continue
- }
-
- [PSCustomObject]@{
- Name = $AppxPackage.Name
- PackageFullName = $AppxPackage.PackageFullName
- DisplayName = $PackageId.DisplayName
- AppxManifest = "$($AppxPackage.InstallLocation)\AppxManifest.xml"
- }
- }
- }
-
- function Add-Control
- {
- [CmdletBinding()]
- param
- (
- [Parameter(
- Mandatory = $true,
- ValueFromPipeline = $true
- )]
- [ValidateNotNull()]
- [PSCustomObject[]]
- $Packages
- )
-
- process
- {
- foreach ($Package in $Packages)
- {
- $CheckBox = New-Object -TypeName System.Windows.Controls.CheckBox
- $CheckBox.Tag = $Package.AppxManifest
-
- $TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
-
- if ($Package.DisplayName)
- {
- $TextBlock.Text = $Package.DisplayName
- }
- else
- {
- $TextBlock.Text = $Package.Name
- }
-
- $StackPanel = New-Object -TypeName System.Windows.Controls.StackPanel
- $StackPanel.Children.Add($CheckBox) | Out-Null
- $StackPanel.Children.Add($TextBlock) | Out-Null
-
- $PanelContainer.Children.Add($StackPanel) | Out-Null
-
- $CheckBox.IsChecked = $true
- $PackagesToRestore.Add($Package.AppxManifest)
-
- $CheckBox.Add_Click({CheckBoxClick})
- }
- }
- }
-
- function ButtonRestoreClick
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- $Window.Close() | Out-Null
-
- $Parameters = @{
- Register = $true
- ForceApplicationShutdown = $true
- ForceUpdateFromAnyVersion = $true
- DisableDevelopmentMode = $true
- Verbose = $true
- }
- $PackagesToRestore | Add-AppxPackage @Parameters
- }
-
- function CheckBoxClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Add($CheckBox.Tag) | Out-Null
- }
- else
- {
- $PackagesToRestore.Remove($CheckBox.Tag)
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function CheckBoxSelectAllClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $true
- $PackagesToRestore.Add($Item.Tag)
- }
- }
- }
- else
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $false
- }
- }
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function ButtonRestoreSetIsEnabled
- {
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
- else
- {
- $ButtonRestore.IsEnabled = $false
- }
- }
- #endregion Functions
-
- $PackagesToRestore = [Collections.Generic.List[string]]::new()
- $AppXPackages = Get-AppxManifest
- $AppXPackages | Add-Control
-
- if ($AppxPackages.Count -eq 0)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.NoData -Verbose
- }
- else
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.DialogBoxOpening -Verbose
-
- #region Sendkey function
- # Emulate the Backspace key sending to prevent the console window to freeze
- Start-Sleep -Milliseconds 500
-
- Add-Type -AssemblyName System.Windows.Forms
-
- Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
- # Show window, if minimized
- [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
-
- Start-Sleep -Seconds 1
-
- # Force move the console window to the foreground
- [WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
-
- Start-Sleep -Seconds 1
-
- # Emulate the Backspace key sending to prevent the console window to freeze
- [System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
- }
- #endregion Sendkey function
-
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
-
- # Force move the WPF form to the foreground
- $Window.Add_Loaded({$Window.Activate()})
- $Form.ShowDialog() | Out-Null
- }
-}
-
<#
.SYNOPSIS
"HEVC Video Extensions from Device Manufacturer" extension
@@ -15202,7 +14600,7 @@ function UseStoreOpenWith
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1
index 807c84b3..b334d6d4 100644
--- a/src/Sophia_Script_for_Windows_10/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_10/Sophia.ps1
@@ -605,7 +605,7 @@ NavigationPaneExpand -Disable
# OneDrive -Install
# Install OneDrive 64-bit all users to %ProgramFiles% depending which installer is triggered
-# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от от того, как запускается инсталлятор
+# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от того, как запускается инсталлятор
# OneDrive -Install -AllUsers
#endregion OneDrive
@@ -644,14 +644,6 @@ Hibernation -Disable
# Включить режим гибернации (значение по умолчанию)
# Hibernation -Enable
-# Change the %TEMP% environment variable path to %SystemDrive%\Temp
-# Изменить путь переменной среды для %TEMP% на %SystemDrive%\Temp
-# TempFolder -SystemDrive
-
-# Change %TEMP% environment variable path to %LOCALAPPDATA%\Temp (default value)
-# Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\Temp (значение по умолчанию)
-# TempFolder -Default
-
# Disable the Windows 260 characters path limit
# Отключить ограничение Windows на 260 символов в пути
Win32LongPathLimit -Disable
@@ -831,7 +823,7 @@ LatestInstalled.NET -Enable
The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled
Otherwise the backup functionality for the "Desktop" and "Pictures" folders in OneDrive breaks
- Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе
+ Сохранять скриншоты по нажатию Win+PrtScr на рабочий стол
Функция будет применена только в случае, если в пресете настроено удаление приложения OneDrive или приложение уже удалено,
иначе в OneDrive ломается функционал резервного копирования для папок "Рабочий стол" и "Изображения"
#>
@@ -1104,24 +1096,13 @@ PinToStart -Tiles ControlPanel, DevicesPrinters
#region UWP apps
<#
- Uninstall UWP apps using the pop-up dialog box
+ Uninstall UWP apps for all users using the pop-up dialog box
If the "For All Users" is checked apps packages will not be installed for new users
- The "ForAllUsers" argument sets a checkbox to unistall packages for all users
- Удалить UWP-приложения, используя всплывающее диалоговое окно
+ Удалить UWP-приложения для всех пользователей, используя всплывающее диалоговое окно
Пакеты приложений не будут установлены для новых пользователей, если отмечена галочка "Для всех пользователей"
- Аргумент "ForAllUsers" устанавливает галочку для удаления пакетов для всех пользователей
-#>
-UninstallUWPApps
-
-<#
- Restore the default UWP apps using the pop-up dialog box
- UWP apps can be restored only if they were uninstalled only for the current user
-
- Восстановить стандартные UWP-приложения, используя всплывающее диалоговое окно
- UWP-приложения могут быть восстановлены, только если они были удалены для текущего пользователя
#>
-# RestoreUWPApps
+# UninstallUWPApps -ForAllUsers
# Download and install "HEVC Video Extensions from Device Manufacturer" to be able to open .heic and .heif formats
# Скачать и установить "Расширения для видео HEVC от производителя устройства", чтобы иметь возможность открывать форматы .heic и .heif
diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
index 57176d3b..1b45aa31 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
@@ -225,8 +225,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
"Ghost Toolbox" = "$env:SystemRoot\System32\migwiz\dlmanifests\run.ghost.cmd"
# https://win10tweaker.ru
"Win 10 Tweaker" = "HKCU:\Software\Win 10 Tweaker"
- # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
- "Modern Tweaker" = "Registry::HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\Modern Cleaner"
# https://boosterx.ru
BoosterX = "$env:ProgramFiles\GameModeX\GameModeX.exe"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=400#11
@@ -245,6 +243,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
winutil = "$env:TEMP\Winutil.log"
# https://www.youtube.com/watch?v=5NBqbUUB1Pk
WinClean = "$env:ProgramFiles\WinClean Plus Apps"
+ # https://github.com/Atlas-OS/Atlas
+ AtlasOS = "$env:SystemRoot\AtlasModules"
+ # https://www.gearupbooster.com
+ "GearUP Booster" = "${env:ProgramFiles(x86)}\GearUPBooster"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -278,13 +280,15 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Check whether Windows was broken by 3rd party harmful tweakers and trojans
$Tweakers = @{
# https://forum.ru-board.com/topic.cgi?forum=62&topic=30617&start=1600#14
- AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
+ AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
# Flibustier custom Windows image
- Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
+ Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
# https://github.com/hellzerg/optimizer
- Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
+ Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
# https://github.com/builtbybel/Winpilot
- Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
+ "Modern Tweaker" = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Modern Tweaker`"})"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -1873,7 +1877,7 @@ function AdvertisingID
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
@@ -4260,296 +4264,6 @@ function Hibernation
}
}
-<#
- .SYNOPSIS
- The %TEMP% environment variable path
-
- .PARAMETER SystemDrive
- Change the %TEMP% environment variable path to %SystemDrive%\Temp
-
- .PARAMETER Default
- Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
-
- .EXAMPLE
- TempFolder -SystemDrive
-
- .EXAMPLE
- TempFolder -Default
-
- .NOTES
- Machine-wide
-#>
-function TempFolder
-{
- param
- (
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "SystemDrive"
- )]
- [switch]
- $SystemDrive,
-
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Default"
- )]
- [switch]
- $Default
- )
-
- switch ($PSCmdlet.ParameterSetName)
- {
- "SystemDrive"
- {
- if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:SystemDrive\Temp))
- {
- New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
- }
-
- # Cleaning up folders
- Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore
- Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # If there are some files or folders left in %LOCALAPPDATA\Temp%
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- $SymbolicLinkTask = @"
-Get-ChildItem -Path `$env:LOCALAPPDATA\Temp -Recurse -Force | Remove-Item -Recurse -Force
-
-Get-Item -Path `$env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {`$_.LinkType -ne """SymbolicLink"""} | Remove-Item -Recurse -Force
-New-Item -Path `$env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value `$env:SystemDrive\Temp -Force
-
-Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SymbolicLinkTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "SymbolicLink"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
- else
- {
- # Create a symbolic link to the %SystemDrive%\Temp folder
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- # The additional registry key creating are needed to fix the property type of the keys: SetEnvironmentVariable creates them with the "String" type instead of "ExpandString" as by default
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
- }
- "Default"
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- # Remove a symbolic link to the %SystemDrive%\Temp folder
- if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
- {
- (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete()
- }
-
- if (-not (Test-Path -Path $env:SystemRoot\Temp))
- {
- New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force
- }
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # Removing folders
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Ignore
-
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- $TempFolder = (Get-Item -Path $env:TEMP).FullName
- $TempFolderCleanupTask = @"
-Remove-Item -Path "$TempFolder" -Recurse -Force
-Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to clean up the temporary folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempFolderCleanupTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "TemporaryTask"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- }
- }
-}
-
<#
.SYNOPSIS
The Windows 260 character path limit
diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
index b67f1f52..48b66687 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
@@ -485,14 +485,6 @@ Hibernation -Disable
# Включить режим гибернации (значение по умолчанию)
# Hibernation -Enable
-# Change the %TEMP% environment variable path to %SystemDrive%\Temp
-# Изменить путь переменной среды для %TEMP% на %SystemDrive%\Temp
-# TempFolder -SystemDrive
-
-# Change %TEMP% environment variable path to %LOCALAPPDATA%\Temp (default value)
-# Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\Temp (значение по умолчанию)
-# TempFolder -Default
-
# Disable the Windows 260 characters path limit
# Отключить ограничение Windows на 260 символов в пути
Win32LongPathLimit -Disable
@@ -668,7 +660,7 @@ LatestInstalled.NET -Enable
# LatestInstalled.NET -Disable
# Save screenshots by pressing Win+PrtScr on the Desktop
-# Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе
+# Сохранять скриншоты по нажатию Win+PrtScr на рабочий стол
WinPrtScrFolder -Desktop
# Save screenshots by pressing Win+PrtScr in the Pictures folder (default value)
diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
index 5baaca50..18fe2b26 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
@@ -225,8 +225,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
"Ghost Toolbox" = "$env:SystemRoot\System32\migwiz\dlmanifests\run.ghost.cmd"
# https://win10tweaker.ru
"Win 10 Tweaker" = "HKCU:\Software\Win 10 Tweaker"
- # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
- "Modern Tweaker" = "Registry::HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\Modern Cleaner"
# https://boosterx.ru
BoosterX = "$env:ProgramFiles\GameModeX\GameModeX.exe"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=400#11
@@ -245,6 +243,10 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
winutil = "$env:TEMP\Winutil.log"
# https://www.youtube.com/watch?v=5NBqbUUB1Pk
WinClean = "$env:ProgramFiles\WinClean Plus Apps"
+ # https://github.com/Atlas-OS/Atlas
+ AtlasOS = "$env:SystemRoot\AtlasModules"
+ # https://www.gearupbooster.com
+ "GearUP Booster" = "${env:ProgramFiles(x86)}\GearUPBooster"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -278,13 +280,15 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Check whether Windows was broken by 3rd party harmful tweakers and trojans
$Tweakers = @{
# https://forum.ru-board.com/topic.cgi?forum=62&topic=30617&start=1600#14
- AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
+ AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
# Flibustier custom Windows image
- Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
+ Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
# https://github.com/hellzerg/optimizer
- Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
+ Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
# https://github.com/builtbybel/Winpilot
- Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
+ "Modern Tweaker" = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Modern Tweaker`"})"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -1873,7 +1877,7 @@ function AdvertisingID
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
@@ -4636,296 +4640,6 @@ function Hibernation
}
}
-<#
- .SYNOPSIS
- The %TEMP% environment variable path
-
- .PARAMETER SystemDrive
- Change the %TEMP% environment variable path to %SystemDrive%\Temp
-
- .PARAMETER Default
- Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
-
- .EXAMPLE
- TempFolder -SystemDrive
-
- .EXAMPLE
- TempFolder -Default
-
- .NOTES
- Machine-wide
-#>
-function TempFolder
-{
- param
- (
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "SystemDrive"
- )]
- [switch]
- $SystemDrive,
-
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Default"
- )]
- [switch]
- $Default
- )
-
- switch ($PSCmdlet.ParameterSetName)
- {
- "SystemDrive"
- {
- if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:SystemDrive\Temp))
- {
- New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
- }
-
- # Cleaning up folders
- Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore
- Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # If there are some files or folders left in %LOCALAPPDATA\Temp%
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- $SymbolicLinkTask = @"
-Get-ChildItem -Path `$env:LOCALAPPDATA\Temp -Recurse -Force | Remove-Item -Recurse -Force
-
-Get-Item -Path `$env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {`$_.LinkType -ne """SymbolicLink"""} | Remove-Item -Recurse -Force
-New-Item -Path `$env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value `$env:SystemDrive\Temp -Force
-
-Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SymbolicLinkTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "SymbolicLink"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
- else
- {
- # Create a symbolic link to the %SystemDrive%\Temp folder
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- # The additional registry key creating are needed to fix the property type of the keys: SetEnvironmentVariable creates them with the "String" type instead of "ExpandString" as by default
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
- }
- "Default"
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- # Remove a symbolic link to the %SystemDrive%\Temp folder
- if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
- {
- (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete()
- }
-
- if (-not (Test-Path -Path $env:SystemRoot\Temp))
- {
- New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force
- }
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # Removing folders
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Ignore
-
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- $TempFolder = (Get-Item -Path $env:TEMP).FullName
- $TempFolderCleanupTask = @"
-Remove-Item -Path "$TempFolder" -Recurse -Force
-Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to clean up the temporary folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempFolderCleanupTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "TemporaryTask"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- }
- }
-}
-
<#
.SYNOPSIS
The Windows 260 character path limit
@@ -7333,6 +7047,24 @@ function RecommendedTroubleshooting
New-Item -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 3 -Force
+
+ # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
+ if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
+ {
+ New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
+ }
+ New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
+
+ Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 3
+
+ # Turn on Windows Error Reporting
+ Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
+ Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
+
+ Get-Service -Name WerSvc | Set-Service -StartupType Manual
+ Get-Service -Name WerSvc | Start-Service
}
"Default"
{
@@ -7343,24 +7075,6 @@ function RecommendedTroubleshooting
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 2 -Force
}
}
-
- # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
- if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
- {
- New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
- }
- New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
-
- Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1
-
- # Turn on Windows Error Reporting
- Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
- Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
-
- Get-Service -Name WerSvc | Set-Service -StartupType Manual
- Get-Service -Name WerSvc | Start-Service
}
<#
@@ -9719,7 +9433,7 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
- (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
+ $Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Alias" = $_.Name
diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
index 5ff43b76..ed75e4e1 100644
--- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
@@ -541,14 +541,6 @@ Hibernation -Disable
# Включить режим гибернации (значение по умолчанию)
# Hibernation -Enable
-# Change the %TEMP% environment variable path to %SystemDrive%\Temp
-# Изменить путь переменной среды для %TEMP% на %SystemDrive%\Temp
-# TempFolder -SystemDrive
-
-# Change %TEMP% environment variable path to %LOCALAPPDATA%\Temp (default value)
-# Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\Temp (значение по умолчанию)
-# TempFolder -Default
-
# Disable the Windows 260 characters path limit
# Отключить ограничение Windows на 260 символов в пути
Win32LongPathLimit -Disable
@@ -724,7 +716,7 @@ LatestInstalled.NET -Enable
# LatestInstalled.NET -Disable
# Save screenshots by pressing Win+PrtScr on the Desktop
-# Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе
+# Сохранять скриншоты по нажатию Win+PrtScr на рабочий стол
WinPrtScrFolder -Desktop
# Save screenshots by pressing Win+PrtScr in the Pictures folder (default value)
diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
index 80df1c01..4c426213 100644
--- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
+++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
@@ -58,7 +58,7 @@ function InitialActions
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Import PowerShell 5.1 modules
- Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell
+ Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx, DISM -UseWindowsPowerShell
# Extract strings from %SystemRoot%\System32\shell32.dll using its number
# https://github.com/SamuelArnold/StarKill3r/blob/master/Star%20Killer/Star%20Killer/bin/Debug/Scripts/SANS-SEC505-master/scripts/Day1-PowerShell/Expand-IndirectString.ps1
@@ -224,8 +224,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
"Ghost Toolbox" = "$env:SystemRoot\System32\migwiz\dlmanifests\run.ghost.cmd"
# https://win10tweaker.ru
"Win 10 Tweaker" = "HKCU:\Software\Win 10 Tweaker"
- # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
- "Modern Tweaker" = "Registry::HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\Modern Cleaner"
# https://boosterx.ru
BoosterX = "$env:ProgramFiles\GameModeX\GameModeX.exe"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=400#11
@@ -246,6 +244,8 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
WinClean = "$env:ProgramFiles\WinClean Plus Apps"
# https://github.com/Atlas-OS/Atlas
AtlasOS = "$env:SystemRoot\AtlasModules"
+ # https://www.gearupbooster.com
+ "GearUP Booster" = "${env:ProgramFiles(x86)}\GearUPBooster"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -279,13 +279,15 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Check whether Windows was broken by 3rd party harmful tweakers and trojans
$Tweakers = @{
# https://forum.ru-board.com/topic.cgi?forum=62&topic=30617&start=1600#14
- AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
+ AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
# Flibustier custom Windows image
- Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
+ Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
# https://github.com/hellzerg/optimizer
- Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
+ Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
# https://github.com/builtbybel/Winpilot
- Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
+ "Modern Tweaker" = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Modern Tweaker`"})"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -306,8 +308,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# https://github.com/PowerShell/PowerShell/issues/21295
try
{
- # Import PowerShell 5.1 DISM module
- Import-Module -Name DISM -UseWindowsPowerShell
Get-WindowsEdition -Online
}
catch [System.Runtime.InteropServices.COMException]
@@ -1926,7 +1926,7 @@ function AdvertisingID
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
@@ -5127,10 +5127,6 @@ function OneDrive
[switch]
$Install,
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Install"
- )]
[switch]
$AllUsers
)
@@ -5139,7 +5135,9 @@ function OneDrive
{
"Uninstall"
{
- [string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
+ # {$_.Meta.Attributes["UninstallString"]} is broken
+ [xml]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.SwidTagText}
+ [string]$UninstallString = $UninstallString.SoftwareIdentity.Meta.UninstallString
if (-not $UninstallString)
{
Write-Information -MessageData "" -InformationAction Continue
@@ -5300,11 +5298,11 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe
}
}
else
@@ -5339,7 +5337,7 @@ public static bool MarkFileDelete (string sourcefile)
# Remove invalid chars
[xml]$OneDriveXML = $Content -replace "", ""
- $OneDriveURL = ($OneDriveXML).root.update.amd64binary.url | Select-Object -Index 1
+ $OneDriveURL = $OneDriveXML.root.update.amd64binary.url | Select-Object -Index 1
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $OneDriveURL
@@ -5352,7 +5350,7 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
@@ -5611,296 +5609,6 @@ function Hibernation
}
}
-<#
- .SYNOPSIS
- The %TEMP% environment variable path
-
- .PARAMETER SystemDrive
- Change the %TEMP% environment variable path to %SystemDrive%\Temp
-
- .PARAMETER Default
- Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
-
- .EXAMPLE
- TempFolder -SystemDrive
-
- .EXAMPLE
- TempFolder -Default
-
- .NOTES
- Machine-wide
-#>
-function TempFolder
-{
- param
- (
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "SystemDrive"
- )]
- [switch]
- $SystemDrive,
-
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Default"
- )]
- [switch]
- $Default
- )
-
- switch ($PSCmdlet.ParameterSetName)
- {
- "SystemDrive"
- {
- if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:SystemDrive\Temp))
- {
- New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
- }
-
- # Cleaning up folders
- Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore
- Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # If there are some files or folders left in %LOCALAPPDATA\Temp%
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerOptions = $CompilerOptions
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- $SymbolicLinkTask = @"
-Get-ChildItem -Path `$env:LOCALAPPDATA\Temp -Recurse -Force | Remove-Item -Recurse -Force
-
-Get-Item -Path `$env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {`$_.LinkType -ne """SymbolicLink"""} | Remove-Item -Recurse -Force
-New-Item -Path `$env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value `$env:SystemDrive\Temp -Force
-
-Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SymbolicLinkTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "SymbolicLink"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
- else
- {
- # Create a symbolic link to the %SystemDrive%\Temp folder
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- # The additional registry key creating are needed to fix the property type of the keys: SetEnvironmentVariable creates them with the "String" type instead of "ExpandString" as by default
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
- }
- "Default"
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- # Remove a symbolic link to the %SystemDrive%\Temp folder
- if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
- {
- (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete()
- }
-
- if (-not (Test-Path -Path $env:SystemRoot\Temp))
- {
- New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force
- }
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # Removing folders
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Ignore
-
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerOptions = $CompilerOptions
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- $TempFolder = (Get-Item -Path $env:TEMP).FullName
- $TempFolderCleanupTask = @"
-Remove-Item -Path "$TempFolder" -Recurse -Force
-Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to clean up the temporary folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempFolderCleanupTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "TemporaryTask"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- }
- }
-}
-
<#
.SYNOPSIS
The Windows 260 character path limit
@@ -8366,6 +8074,24 @@ function RecommendedTroubleshooting
New-Item -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 3 -Force
+
+ # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
+ if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
+ {
+ New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
+ }
+ New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
+
+ Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 3
+
+ # Turn on Windows Error Reporting
+ Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
+ Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
+
+ Get-Service -Name WerSvc | Set-Service -StartupType Manual
+ Get-Service -Name WerSvc | Start-Service
}
"Default"
{
@@ -8376,24 +8102,6 @@ function RecommendedTroubleshooting
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 2 -Force
}
}
-
- # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
- if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
- {
- New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
- }
- New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
-
- Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1
-
- # Turn on Windows Error Reporting
- Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
- Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
-
- Get-Service -Name WerSvc | Set-Service -StartupType Manual
- Get-Service -Name WerSvc | Start-Service
}
<#
@@ -10855,7 +10563,7 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
- (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
+ $Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Alias" = $_.Name
@@ -11849,326 +11557,6 @@ function UninstallUWPApps
}
}
-<#
- .SYNOPSIS
- Restore the default UWP apps
-
- .EXAMPLE
- RestoreUWPAppsUWPApps
-
- .NOTES
- UWP apps can be restored only if they were uninstalled for the current user
-
- .LINK
- https://github.com/microsoft/CsWinRT
- https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref
-
- .NOTES
- Load the WinRT.Runtime.dll and Microsoft.Windows.SDK.NET.dll assemblies in the current session in order to get localized UWP apps names
-
- .NOTES
- Current user
-#>
-function RestoreUWPApps
-{
- Add-Type -AssemblyName "$PSScriptRoot\..\bin\WinRT.Runtime.dll"
- Add-Type -AssemblyName "$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll"
-
- Add-Type -AssemblyName PresentationCore, PresentationFramework
-
- #region Variables
- #region XAML Markup
- # The section defines the design of the upcoming dialog box
- [xml]$XAML = @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-"@
- #endregion XAML Markup
-
- $Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $XAML))
- $XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
- Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)
- }
-
- $Window.Title = $Localization.UWPAppsTitle
- $ButtonRestore.Content = $Localization.Restore
- # Extract the localized "Select all" string from shell32.dll
- $TextBlockSelectAll.Text = [WinAPI.GetStrings]::GetString(31276)
-
- $ButtonRestore.Add_Click({ButtonRestoreClick})
- $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
- #endregion Variables
-
- #region Functions
- function Get-AppxManifest
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- # You cannot retrieve packages using -PackageTypeFilter Bundle, otherwise you won't get the InstallLocation attribute. It can be retrieved only by comparing with $Bundles
- $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
- $AppxPackages = @(Get-AppxPackage -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Where-Object -FilterScript {$_.Name -in $Bundles})
-
- # The Bundle packages contains no Microsoft Teams
- if (Get-AppxPackage -Name MicrosoftTeams -AllUsers)
- {
- $AppxPackages += Get-AppxPackage -Name MicrosoftTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"}
- }
-
- $PackagesIds = [Windows.Management.Deployment.PackageManager, Windows.Web, ContentType = WindowsRuntime]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName
-
- foreach ($AppxPackage in $AppxPackages)
- {
- $PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name}
-
- if (-not $PackageId)
- {
- continue
- }
-
- [PSCustomObject]@{
- Name = $AppxPackage.Name
- PackageFullName = $AppxPackage.PackageFullName
- DisplayName = $PackageId.DisplayName
- AppxManifest = "$($AppxPackage.InstallLocation)\AppxManifest.xml"
- }
- }
- }
-
- function Add-Control
- {
- [CmdletBinding()]
- param
- (
- [Parameter(
- Mandatory = $true,
- ValueFromPipeline = $true
- )]
- [ValidateNotNull()]
- [PSCustomObject[]]
- $Packages
- )
-
- process
- {
- foreach ($Package in $Packages)
- {
- $CheckBox = New-Object -TypeName System.Windows.Controls.CheckBox
- $CheckBox.Tag = $Package.AppxManifest
-
- $TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
-
- if ($Package.DisplayName)
- {
- $TextBlock.Text = $Package.DisplayName
- }
- else
- {
- $TextBlock.Text = $Package.Name
- }
-
- $StackPanel = New-Object -TypeName System.Windows.Controls.StackPanel
- $StackPanel.Children.Add($CheckBox) | Out-Null
- $StackPanel.Children.Add($TextBlock) | Out-Null
-
- $PanelContainer.Children.Add($StackPanel) | Out-Null
-
- $CheckBox.IsChecked = $true
- $PackagesToRestore.Add($Package.AppxManifest)
-
- $CheckBox.Add_Click({CheckBoxClick})
- }
- }
- }
-
- function ButtonRestoreClick
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- $Window.Close() | Out-Null
-
- $Parameters = @{
- Register = $true
- ForceApplicationShutdown = $true
- ForceUpdateFromAnyVersion = $true
- DisableDevelopmentMode = $true
- Verbose = $true
- }
- $PackagesToRestore | Add-AppxPackage @Parameters
- }
-
- function CheckBoxClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Add($CheckBox.Tag) | Out-Null
- }
- else
- {
- $PackagesToRestore.Remove($CheckBox.Tag)
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function CheckBoxSelectAllClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $true
- $PackagesToRestore.Add($Item.Tag)
- }
- }
- }
- else
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $false
- }
- }
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function ButtonRestoreSetIsEnabled
- {
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
- else
- {
- $ButtonRestore.IsEnabled = $false
- }
- }
- #endregion Functions
-
- $PackagesToRestore = [Collections.Generic.List[string]]::new()
- $AppXPackages = Get-AppxManifest
- $AppXPackages | Add-Control
-
- if ($AppxPackages.Count -eq 0)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.NoData -Verbose
- }
- else
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.DialogBoxOpening -Verbose
-
- #region Sendkey function
- # Emulate the Backspace key sending to prevent the console window to freeze
- Start-Sleep -Milliseconds 500
-
- Add-Type -AssemblyName System.Windows.Forms
-
- Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process {
- # Show window, if minimized
- [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
-
- Start-Sleep -Seconds 1
-
- # Force move the console window to the foreground
- [WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
-
- Start-Sleep -Seconds 1
-
- # Emulate the Backspace key sending to prevent the console window to freeze
- [System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
- }
- #endregion Sendkey function
-
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
-
- # Force move the WPF form to the foreground
- $Window.Add_Loaded({$Window.Activate()})
- $Form.ShowDialog() | Out-Null
- }
-}
-
<#
.SYNOPSIS
"HEVC Video Extensions from Device Manufacturer" extension
@@ -15228,7 +14616,7 @@ function UseStoreOpenWith
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
index f3f3a41e..2bd83ee7 100644
--- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
@@ -616,7 +616,7 @@ NavigationPaneExpand -Disable
# OneDrive -Install
# Install OneDrive 64-bit all users to %ProgramFiles% depending which installer is triggered
-# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от от того, как запускается инсталлятор
+# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от того, как запускается инсталлятор
# OneDrive -Install -AllUsers
#endregion OneDrive
@@ -655,14 +655,6 @@ Hibernation -Disable
# Включить режим гибернации (значение по умолчанию)
# Hibernation -Enable
-# Change the %TEMP% environment variable path to %SystemDrive%\Temp
-# Изменить путь переменной среды для %TEMP% на %SystemDrive%\Temp
-# TempFolder -SystemDrive
-
-# Change %TEMP% environment variable path to %LOCALAPPDATA%\Temp (default value)
-# Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\Temp (значение по умолчанию)
-# TempFolder -Default
-
# Disable the Windows 260 characters path limit
# Отключить ограничение Windows на 260 символов в пути
Win32LongPathLimit -Disable
@@ -842,7 +834,7 @@ LatestInstalled.NET -Enable
The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled
Otherwise the backup functionality for the "Desktop" and "Pictures" folders in OneDrive breaks
- Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе
+ Сохранять скриншоты по нажатию Win+PrtScr на рабочий стол
Функция будет применена только в случае, если в пресете настроено удаление приложения OneDrive или приложение уже удалено,
иначе в OneDrive ломается функционал резервного копирования для папок "Рабочий стол" и "Изображения"
#>
@@ -1115,24 +1107,13 @@ PinToStart -Tiles ControlPanel, DevicesPrinters
#region UWP apps
<#
- Uninstall UWP apps using the pop-up dialog box
+ Uninstall UWP apps for all users using the pop-up dialog box
If the "For All Users" is checked apps packages will not be installed for new users
- The "ForAllUsers" argument sets a checkbox to unistall packages for all users
- Удалить UWP-приложения, используя всплывающее диалоговое окно
+ Удалить UWP-приложения для всех пользователей, используя всплывающее диалоговое окно
Пакеты приложений не будут установлены для новых пользователей, если отмечена галочка "Для всех пользователей"
- Аргумент "ForAllUsers" устанавливает галочку для удаления пакетов для всех пользователей
-#>
-UninstallUWPApps
-
-<#
- Restore the default UWP apps using the pop-up dialog box
- UWP apps can be restored only if they were uninstalled only for the current user
-
- Восстановить стандартные UWP-приложения, используя всплывающее диалоговое окно
- UWP-приложения могут быть восстановлены, только если они были удалены для текущего пользователя
#>
-# RestoreUWPApps
+# UninstallUWPApps -ForAllUsers
# Download and install "HEVC Video Extensions from Device Manufacturer" to be able to open .heic and .heif formats
# Скачать и установить "Расширения для видео HEVC от производителя устройства", чтобы иметь возможность открывать форматы .heic и .heif
diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
index 2f15acb6..115cc568 100644
--- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
+++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
@@ -213,8 +213,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
"Ghost Toolbox" = "$env:SystemRoot\System32\migwiz\dlmanifests\run.ghost.cmd"
# https://win10tweaker.ru
"Win 10 Tweaker" = "HKCU:\Software\Win 10 Tweaker"
- # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
- "Modern Tweaker" = "Registry::HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\Modern Cleaner"
# https://boosterx.ru
BoosterX = "$env:ProgramFiles\GameModeX\GameModeX.exe"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=400#11
@@ -235,6 +233,8 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
WinClean = "$env:ProgramFiles\WinClean Plus Apps"
# https://github.com/Atlas-OS/Atlas
AtlasOS = "$env:SystemRoot\AtlasModules"
+ # https://www.gearupbooster.com
+ "GearUP Booster" = "${env:ProgramFiles(x86)}\GearUPBooster"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -268,13 +268,15 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Check whether Windows was broken by 3rd party harmful tweakers and trojans
$Tweakers = @{
# https://forum.ru-board.com/topic.cgi?forum=62&topic=30617&start=1600#14
- AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
+ AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
# Flibustier custom Windows image
- Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
+ Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
# https://github.com/hellzerg/optimizer
- Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
+ Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
# https://github.com/builtbybel/Winpilot
- Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
+ "Modern Tweaker" = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Modern Tweaker`"})"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -592,6 +594,20 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
exit
}
+ if ((Get-WindowsEdition -Online).Edition -match "EnterpriseS")
+ {
+ # Will be removed when Windows 11 Enterprise LTSC will be released officially this Autumn along side with 24H2
+ Write-Information -MessageData "" -InformationAction Continue
+ Write-Warning -Message "You're using a leaked Windows 11 Enterprise LTSC image. The official release set to November."
+ Write-Information -MessageData "" -InformationAction Continue
+
+ Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
+ Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
+ Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows#system-requirements" -Verbose
+
+ exit
+ }
+
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{
@@ -1902,7 +1918,7 @@ function AdvertisingID
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
@@ -4711,10 +4727,6 @@ function OneDrive
[switch]
$Install,
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Install"
- )]
[switch]
$AllUsers
)
@@ -4884,11 +4896,11 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users
- Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
- Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -Wait
+ Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe
}
}
else
@@ -4923,7 +4935,7 @@ public static bool MarkFileDelete (string sourcefile)
# Remove invalid chars
[xml]$OneDriveXML = $Content -replace "", ""
- $OneDriveURL = ($OneDriveXML).root.update.amd64binary.url | Select-Object -Index 1
+ $OneDriveURL = $OneDriveXML.root.update.amd64binary.url | Select-Object -Index 1
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $OneDriveURL
@@ -4936,7 +4948,7 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
@@ -5195,296 +5207,6 @@ function Hibernation
}
}
-<#
- .SYNOPSIS
- The %TEMP% environment variable path
-
- .PARAMETER SystemDrive
- Change the %TEMP% environment variable path to %SystemDrive%\Temp
-
- .PARAMETER Default
- Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
-
- .EXAMPLE
- TempFolder -SystemDrive
-
- .EXAMPLE
- TempFolder -Default
-
- .NOTES
- Machine-wide
-#>
-function TempFolder
-{
- param
- (
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "SystemDrive"
- )]
- [switch]
- $SystemDrive,
-
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Default"
- )]
- [switch]
- $Default
- )
-
- switch ($PSCmdlet.ParameterSetName)
- {
- "SystemDrive"
- {
- if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:SystemDrive\Temp))
- {
- New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
- }
-
- # Cleaning up folders
- Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore
- Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # If there are some files or folders left in %LOCALAPPDATA\Temp%
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- $SymbolicLinkTask = @"
-Get-ChildItem -Path `$env:LOCALAPPDATA\Temp -Recurse -Force | Remove-Item -Recurse -Force
-
-Get-Item -Path `$env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {`$_.LinkType -ne """SymbolicLink"""} | Remove-Item -Recurse -Force
-New-Item -Path `$env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value `$env:SystemDrive\Temp -Force
-
-Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SymbolicLinkTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "SymbolicLink"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
- else
- {
- # Create a symbolic link to the %SystemDrive%\Temp folder
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- # The additional registry key creating are needed to fix the property type of the keys: SetEnvironmentVariable creates them with the "String" type instead of "ExpandString" as by default
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
- }
- "Default"
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- # Remove a symbolic link to the %SystemDrive%\Temp folder
- if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
- {
- (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete()
- }
-
- if (-not (Test-Path -Path $env:SystemRoot\Temp))
- {
- New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force
- }
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # Removing folders
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Ignore
-
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerParameters = $CompilerParameters
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- $TempFolder = (Get-Item -Path $env:TEMP).FullName
- $TempFolderCleanupTask = @"
-Remove-Item -Path "$TempFolder" -Recurse -Force
-Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to clean up the temporary folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempFolderCleanupTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "TemporaryTask"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- }
- }
-}
-
<#
.SYNOPSIS
The Windows 260 character path limit
@@ -8123,7 +7845,7 @@ function WinPrtScrFolder
.NOTES
Machine-wide
#>
-function RecommendedTroubleshooting
+function RecommendedTroubleshooting ###
{
param
(
@@ -8151,6 +7873,24 @@ function RecommendedTroubleshooting
New-Item -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 3 -Force
+
+ # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
+ if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
+ {
+ New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
+ }
+ New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
+
+ Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 3
+
+ # Turn on Windows Error Reporting
+ Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
+ Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
+
+ Get-Service -Name WerSvc | Set-Service -StartupType Manual
+ Get-Service -Name WerSvc | Start-Service
}
"Default"
{
@@ -8161,24 +7901,6 @@ function RecommendedTroubleshooting
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 2 -Force
}
}
-
- # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
- if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
- {
- New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
- }
- New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
-
- Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1
-
- # Turn on Windows Error Reporting
- Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
- Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
-
- Get-Service -Name WerSvc | Set-Service -StartupType Manual
- Get-Service -Name WerSvc | Start-Service
}
<#
@@ -10461,7 +10183,7 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
- (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
+ $Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Alias" = $_.Name
@@ -11169,316 +10891,6 @@ function UninstallUWPApps
}
}
-<#
- .SYNOPSIS
- Restore the default UWP apps
-
- .EXAMPLE
- RestoreUWPAppsUWPApps
-
- .NOTES
- UWP apps can be restored only if they were uninstalled for the current user
-
- .NOTES
- Current user
-#>
-function RestoreUWPApps
-{
- Add-Type -AssemblyName PresentationCore, PresentationFramework
-
- #region Variables
- #region XAML Markup
- # The section defines the design of the upcoming dialog box
- [xml]$XAML = @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-"@
- #endregion XAML Markup
-
- $Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $XAML))
- $XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
- Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)
- }
-
- $Window.Title = $Localization.UWPAppsTitle
- $ButtonRestore.Content = $Localization.Restore
- # Extract the localized "Select all" string from shell32.dll
- $TextBlockSelectAll.Text = [WinAPI.GetStrings]::GetString(31276)
-
- $ButtonRestore.Add_Click({ButtonRestoreClick})
- $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
- #endregion Variables
-
- #region Functions
- function Get-AppxManifest
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- # You cannot retrieve packages using -PackageTypeFilter Bundle, otherwise you won't get the InstallLocation attribute. It can be retrieved only by comparing with $Bundles
- $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
- $AppxPackages = @(Get-AppxPackage -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Where-Object -FilterScript {$_.Name -in $Bundles})
-
- # The Bundle packages contains no Microsoft Teams
- if (Get-AppxPackage -Name MSTeams -AllUsers)
- {
- $AppxPackages += Get-AppxPackage -Name MSTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"}
- }
-
- $PackagesIds = [Windows.Management.Deployment.PackageManager, Windows.Web, ContentType = WindowsRuntime]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName
-
- foreach ($AppxPackage in $AppxPackages)
- {
- $PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name}
-
- if (-not $PackageId)
- {
- continue
- }
-
- [PSCustomObject]@{
- Name = $AppxPackage.Name
- PackageFullName = $AppxPackage.PackageFullName
- DisplayName = $PackageId.DisplayName
- AppxManifest = "$($AppxPackage.InstallLocation)\AppxManifest.xml"
- }
- }
- }
-
- function Add-Control
- {
- [CmdletBinding()]
- param
- (
- [Parameter(
- Mandatory = $true,
- ValueFromPipeline = $true
- )]
- [ValidateNotNull()]
- [PSCustomObject[]]
- $Packages
- )
-
- process
- {
- foreach ($Package in $Packages)
- {
- $CheckBox = New-Object -TypeName System.Windows.Controls.CheckBox
- $CheckBox.Tag = $Package.AppxManifest
-
- $TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
-
- if ($Package.DisplayName)
- {
- $TextBlock.Text = $Package.DisplayName
- }
- else
- {
- $TextBlock.Text = $Package.Name
- }
-
- $StackPanel = New-Object -TypeName System.Windows.Controls.StackPanel
- $StackPanel.Children.Add($CheckBox) | Out-Null
- $StackPanel.Children.Add($TextBlock) | Out-Null
-
- $PanelContainer.Children.Add($StackPanel) | Out-Null
-
- $CheckBox.IsChecked = $true
- $PackagesToRestore.Add($Package.AppxManifest)
-
- $CheckBox.Add_Click({CheckBoxClick})
- }
- }
- }
-
- function ButtonRestoreClick
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- $Window.Close() | Out-Null
-
- $Parameters = @{
- Register = $true
- ForceApplicationShutdown = $true
- ForceUpdateFromAnyVersion = $true
- DisableDevelopmentMode = $true
- Verbose = $true
- }
- $PackagesToRestore | Add-AppxPackage @Parameters
- }
-
- function CheckBoxClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Add($CheckBox.Tag) | Out-Null
- }
- else
- {
- $PackagesToRestore.Remove($CheckBox.Tag)
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function CheckBoxSelectAllClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $true
- $PackagesToRestore.Add($Item.Tag)
- }
- }
- }
- else
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $false
- }
- }
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function ButtonRestoreSetIsEnabled
- {
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
- else
- {
- $ButtonRestore.IsEnabled = $false
- }
- }
- #endregion Functions
-
- $PackagesToRestore = [Collections.Generic.List[string]]::new()
- $AppXPackages = Get-AppxManifest
- $AppXPackages | Add-Control
-
- if ($AppxPackages.Count -eq 0)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.NoData -Verbose
- }
- else
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.DialogBoxOpening -Verbose
-
- #region Sendkey function
- # Emulate the Backspace key sending to prevent the console window to freeze
- Start-Sleep -Milliseconds 500
-
- Add-Type -AssemblyName System.Windows.Forms
-
- Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process {
- # Show window, if minimized
- [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
-
- Start-Sleep -Seconds 1
-
- # Force move the console window to the foreground
- [WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
-
- Start-Sleep -Seconds 1
-
- # Emulate the Backspace key sending to prevent the console window to freeze
- [System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
- }
- #endregion Sendkey function
-
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
-
- # Force move the WPF form to the foreground
- $Window.Add_Loaded({$Window.Activate()})
- $Form.ShowDialog() | Out-Null
- }
-}
-
<#
.SYNOPSIS
Cortana autostarting
@@ -14213,7 +13625,7 @@ function UseStoreOpenWith
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1
index a27c6b7e..740d1063 100644
--- a/src/Sophia_Script_for_Windows_11/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_11/Sophia.ps1
@@ -580,7 +580,7 @@ NavigationPaneExpand -Disable
# OneDrive -Install
# Install OneDrive 64-bit all users to %ProgramFiles% depending which installer is triggered
-# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от от того, как запускается инсталлятор
+# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от того, как запускается инсталлятор
# OneDrive -Install -AllUsers
#endregion OneDrive
@@ -619,14 +619,6 @@ Hibernation -Disable
# Включить режим гибернации (значение по умолчанию)
# Hibernation -Enable
-# Change the %TEMP% environment variable path to %SystemDrive%\Temp
-# Изменить путь переменной среды для %TEMP% на %SystemDrive%\Temp
-# TempFolder -SystemDrive
-
-# Change %TEMP% environment variable path to %LOCALAPPDATA%\Temp (default value)
-# Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\Temp (значение по умолчанию)
-# TempFolder -Default
-
# Disable the Windows 260 characters path limit
# Отключить ограничение Windows на 260 символов в пути
Win32LongPathLimit -Disable
@@ -806,7 +798,7 @@ LatestInstalled.NET -Enable
The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled
Otherwise the backup functionality for the "Desktop" and "Pictures" folders in OneDrive breaks
- Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе
+ Сохранять скриншоты по нажатию Win+PrtScr на рабочий стол
Функция будет применена только в случае, если в пресете настроено удаление приложения OneDrive или приложение уже удалено,
иначе в OneDrive ломается функционал резервного копирования для папок "Рабочий стол" и "Изображения"
#>
@@ -1054,25 +1046,18 @@ StartLayout -ShowMorePins
#endregion Start menu
#region UWP apps
-<#
- Uninstall UWP apps using the pop-up dialog box
- If the "For All Users" is checked apps packages will not be installed for new users
- The "ForAllUsers" argument sets a checkbox to unistall packages for all users
-
- Удалить UWP-приложения, используя всплывающее диалоговое окно
- Пакеты приложений не будут установлены для новых пользователей, если отмечена галочка "Для всех пользователей"
- Аргумент "ForAllUsers" устанавливает галочку для удаления пакетов для всех пользователей
-#>
+# Uninstall UWP apps using the pop-up dialog box
+# Удалить UWP-приложения, используя всплывающее диалоговое окно
UninstallUWPApps
<#
- Restore the default UWP apps using the pop-up dialog box
- UWP apps can be restored only if they were uninstalled only for the current user
+ Uninstall UWP apps for all users using the pop-up dialog box
+ If the "For All Users" is checked apps packages will not be installed for new users
- Восстановить стандартные UWP-приложения, используя всплывающее диалоговое окно
- UWP-приложения могут быть восстановлены, только если они были удалены для текущего пользователя
+ Удалить UWP-приложения для всех пользователей, используя всплывающее диалоговое окно
+ Пакеты приложений не будут установлены для новых пользователей, если отмечена галочка "Для всех пользователей"
#>
-# RestoreUWPApps
+# UninstallUWPApps -ForAllUsers
# Disable Cortana autostarting
# Выключить автозагрузку Кортана
diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
index 1c9dab68..e81e77b2 100644
--- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
+++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
@@ -57,7 +57,7 @@ function InitialActions
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Import PowerShell 5.1 modules
- Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell
+ Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx, DISM -UseWindowsPowerShell
# Extract strings from %SystemRoot%\System32\shell32.dll using its number
# https://github.com/SamuelArnold/StarKill3r/blob/master/Star%20Killer/Star%20Killer/bin/Debug/Scripts/SANS-SEC505-master/scripts/Day1-PowerShell/Expand-IndirectString.ps1
@@ -212,8 +212,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
"Ghost Toolbox" = "$env:SystemRoot\System32\migwiz\dlmanifests\run.ghost.cmd"
# https://win10tweaker.ru
"Win 10 Tweaker" = "HKCU:\Software\Win 10 Tweaker"
- # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
- "Modern Tweaker" = "Registry::HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\Modern Cleaner"
# https://boosterx.ru
BoosterX = "$env:ProgramFiles\GameModeX\GameModeX.exe"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=400#11
@@ -234,6 +232,8 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
WinClean = "$env:ProgramFiles\WinClean Plus Apps"
# https://github.com/Atlas-OS/Atlas
AtlasOS = "$env:SystemRoot\AtlasModules"
+ # https://www.gearupbooster.com
+ "GearUP Booster" = "${env:ProgramFiles(x86)}\GearUPBooster"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -267,13 +267,15 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# Check whether Windows was broken by 3rd party harmful tweakers and trojans
$Tweakers = @{
# https://forum.ru-board.com/topic.cgi?forum=62&topic=30617&start=1600#14
- AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
+ AutoSettingsPS = "$(Get-Item -Path `"HKLM:\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths`" | Where-Object -FilterScript {$_.Property -match `"AutoSettingsPS`"})"
# Flibustier custom Windows image
- Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
+ Flibustier = "$(Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)"
# https://github.com/hellzerg/optimizer
- Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
+ Optimizer = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"optimizer`"})"
# https://github.com/builtbybel/Winpilot
- Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ Winpilot = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Winpilot`"})"
+ # https://forum.ru-board.com/topic.cgi?forum=5&topic=50519
+ "Modern Tweaker" = "$((Get-ItemProperty -Path `"HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache`").PSObject.Properties | Where-Object -FilterScript {$_.Value -eq `"Modern Tweaker`"})"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@@ -294,8 +296,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
# https://github.com/PowerShell/PowerShell/issues/21295
try
{
- # Import PowerShell 5.1 DISM module
- Import-Module -Name DISM -UseWindowsPowerShell
Get-WindowsEdition -Online
}
catch [System.Runtime.InteropServices.COMException]
@@ -306,7 +306,7 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
exit
}
-
+pause
# Check whether Windows Feature Experience Pack was removed by harmful tweakers
if (-not (Get-AppxPackage -Name MicrosoftWindows.Client.CBS))
{
@@ -598,6 +598,18 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
exit
}
+ if ((Get-WindowsEdition -Online).Edition -notmatch "EnterpriseS")
+ {
+ # Will be removed when Windows 11 Enterprise LTSC will be released officially this Autumn along side with 24H2
+ Write-Warning -Message "You're using a leaked Windows 11 Enterprise LTSC image. The official release set to November."
+
+ Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
+ Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
+ Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows#system-requirements" -Verbose
+
+ exit
+ }
+
# Detect Windows build version
switch ((Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber)
{
@@ -1908,7 +1920,7 @@ function AdvertisingID
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo -Name DisabledByGroupPolicy -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name DisabledByGroupPolicy -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
@@ -4717,10 +4729,6 @@ function OneDrive
[switch]
$Install,
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Install"
- )]
[switch]
$AllUsers
)
@@ -4729,7 +4737,9 @@ function OneDrive
{
"Uninstall"
{
- [string]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.Meta.Attributes["UninstallString"]}
+ # {$_.Meta.Attributes["UninstallString"]} is broken
+ [xml]$UninstallString = Get-Package -Name "Microsoft OneDrive" -ProviderName Programs -ErrorAction Ignore | ForEach-Object -Process {$_.SwidTagText}
+ [string]$UninstallString = $UninstallString.SoftwareIdentity.Meta.UninstallString
if (-not $UninstallString)
{
Write-Information -MessageData "" -InformationAction Continue
@@ -4890,11 +4900,11 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users
- Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
- Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe -Wait
+ Start-Process -FilePath $env:SystemRoot\System32\OneDriveSetup.exe
}
}
else
@@ -4929,7 +4939,7 @@ public static bool MarkFileDelete (string sourcefile)
# Remove invalid chars
[xml]$OneDriveXML = $Content -replace "", ""
- $OneDriveURL = ($OneDriveXML).root.update.amd64binary.url | Select-Object -Index 1
+ $OneDriveURL = $OneDriveXML.root.update.amd64binary.url | Select-Object -Index 1
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = $OneDriveURL
@@ -4942,7 +4952,7 @@ public static bool MarkFileDelete (string sourcefile)
if ($AllUsers)
{
# Install OneDrive for all users to %ProgramFiles%
- Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers" -Wait
+ Start-Process -FilePath $env:SystemRoot\SysWOW64\OneDriveSetup.exe -ArgumentList "/allusers"
}
else
{
@@ -5201,296 +5211,6 @@ function Hibernation
}
}
-<#
- .SYNOPSIS
- The %TEMP% environment variable path
-
- .PARAMETER SystemDrive
- Change the %TEMP% environment variable path to %SystemDrive%\Temp
-
- .PARAMETER Default
- Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
-
- .EXAMPLE
- TempFolder -SystemDrive
-
- .EXAMPLE
- TempFolder -Default
-
- .NOTES
- Machine-wide
-#>
-function TempFolder
-{
- param
- (
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "SystemDrive"
- )]
- [switch]
- $SystemDrive,
-
- [Parameter(
- Mandatory = $true,
- ParameterSetName = "Default"
- )]
- [switch]
- $Default
- )
-
- switch ($PSCmdlet.ParameterSetName)
- {
- "SystemDrive"
- {
- if ((Get-LocalUser | Where-Object -FilterScript {$_.Enabled}).Count -gt 1)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:SystemDrive\Temp))
- {
- New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
- }
-
- # Cleaning up folders
- Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore
- Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore
-
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # If there are some files or folders left in %LOCALAPPDATA\Temp%
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerOptions = $CompilerOptions
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- $SymbolicLinkTask = @"
-Get-ChildItem -Path `$env:LOCALAPPDATA\Temp -Recurse -Force | Remove-Item -Recurse -Force
-
-Get-Item -Path `$env:LOCALAPPDATA\Temp -Force | Where-Object -FilterScript {`$_.LinkType -ne """SymbolicLink"""} | Remove-Item -Recurse -Force
-New-Item -Path `$env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value `$env:SystemDrive\Temp -Force
-
-Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $SymbolicLinkTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "SymbolicLink"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
- else
- {
- # Create a symbolic link to the %SystemDrive%\Temp folder
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType SymbolicLink -Value $env:SystemDrive\Temp -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- # The additional registry key creating are needed to fix the property type of the keys: SetEnvironmentVariable creates them with the "String" type instead of "ExpandString" as by default
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemDrive\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value $env:SystemDrive\Temp -Force
- }
- "Default"
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.Skipped -Verbose
-
- return
- }
-
- # Restart the Printer Spooler service (Spooler)
- Restart-Service -Name Spooler -Force
-
- # Stop OneDrive processes
- Stop-Process -Name OneDrive, FileCoAuth -Force -ErrorAction Ignore
-
- # Remove a symbolic link to the %SystemDrive%\Temp folder
- if (Get-Item -Path $env:LOCALAPPDATA\Temp -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -eq "SymbolicLink"})
- {
- (Get-Item -Path $env:LOCALAPPDATA\Temp -Force).Delete()
- }
-
- if (-not (Test-Path -Path $env:SystemRoot\Temp))
- {
- New-Item -Path $env:SystemRoot\Temp -ItemType Directory -Force
- }
- if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp))
- {
- New-Item -Path $env:LOCALAPPDATA\Temp -ItemType Directory -Force
- }
-
- # Removing folders
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Ignore
-
- if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0)
- {
- # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa
- # The system does not move the file until the operating system is restarted
- # The system moves the file immediately after AUTOCHK is executed, but before creating any paging files
- $Signature = @{
- Namespace = "WinAPI"
- Name = "DeleteFiles"
- Language = "CSharp"
- CompilerOptions = $CompilerOptions
- MemberDefinition = @"
-public enum MoveFileFlags
-{
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
-}
-
-[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
-static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
-
-public static bool MarkFileDelete (string sourcefile)
-{
- return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
-}
-"@
- }
-
- if (-not ("WinAPI.DeleteFiles" -as [type]))
- {
- Add-Type @Signature
- }
-
- try
- {
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
- }
- catch
- {
- # If files are in use remove them at the next boot
- Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)}
- }
-
- # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
- # https://github.com/PowerShell/PowerShell/issues/21070
- $TempFolder = (Get-Item -Path $env:TEMP).FullName
- $TempFolderCleanupTask = @"
-Remove-Item -Path "$TempFolder" -Recurse -Force
-Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false
-"@
-
- # Create a temporary scheduled task to clean up the temporary folder
- # We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
- # https://github.com/PowerShell/PowerShell/issues/21377
- $Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $TempFolderCleanupTask"
- $Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
- $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
- $Principal = New-ScheduledTaskPrincipal -UserId "$env:COMPUTERNAME\$env:USERNAME" -RunLevel Highest
- $Parameters = @{
- TaskName = "TemporaryTask"
- Principal = $Principal
- Action = $Action
- Settings = $Settings
- Trigger = $Trigger
- }
- Register-ScheduledTask @Parameters -Force
- }
-
- # Change the %TEMP% environment variable path to %LOCALAPPDATA%\Temp
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "User")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:SystemRoot\TEMP", "Machine")
- [Environment]::SetEnvironmentVariable("TEMP", "$env:LOCALAPPDATA\Temp", "Process")
- New-ItemProperty -Path HKCU:\Environment -Name TEMP -PropertyType ExpandString -Value "%USERPROFILE%\AppData\Local\Temp" -Force
-
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name TEMP -PropertyType ExpandString -Value "%SystemRoot%\TEMP" -Force
- }
- }
-}
-
<#
.SYNOPSIS
The Windows 260 character path limit
@@ -8157,6 +7877,24 @@ function RecommendedTroubleshooting
New-Item -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 3 -Force
+
+ # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
+ if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
+ {
+ New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
+ }
+ New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
+ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
+
+ Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 3
+
+ # Turn on Windows Error Reporting
+ Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
+ Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
+
+ Get-Service -Name WerSvc | Set-Service -StartupType Manual
+ Get-Service -Name WerSvc | Start-Service
}
"Default"
{
@@ -8167,24 +7905,6 @@ function RecommendedTroubleshooting
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 2 -Force
}
}
-
- # Set Windows level of diagnostic data gathering to "Optional diagnostic data"
- if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack))
- {
- New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Force
- }
- New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force
- New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
-
- Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 1
-
- # Turn on Windows Error Reporting
- Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
- Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore
-
- Get-Service -Name WerSvc | Set-Service -StartupType Manual
- Get-Service -Name WerSvc | Start-Service
}
<#
@@ -10467,7 +10187,7 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
- (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
+ $Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Alias" = $_.Name
@@ -11185,326 +10905,6 @@ function UninstallUWPApps
}
}
-<#
- .SYNOPSIS
- Restore the default UWP apps
-
- .EXAMPLE
- RestoreUWPAppsUWPApps
-
- .NOTES
- UWP apps can be restored only if they were uninstalled for the current user
-
- .LINK
- https://github.com/microsoft/CsWinRT
- https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref
-
- .NOTES
- Load the WinRT.Runtime.dll and Microsoft.Windows.SDK.NET.dll assemblies in the current session in order to get localized UWP apps names
-
- .NOTES
- Current user
-#>
-function RestoreUWPApps
-{
- Add-Type -AssemblyName "$PSScriptRoot\..\bin\WinRT.Runtime.dll"
- Add-Type -AssemblyName "$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll"
-
- Add-Type -AssemblyName PresentationCore, PresentationFramework
-
- #region Variables
- #region XAML Markup
- # The section defines the design of the upcoming dialog box
- [xml]$XAML = @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-"@
- #endregion XAML Markup
-
- $Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $XAML))
- $XAML.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | ForEach-Object -Process {
- Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)
- }
-
- $Window.Title = $Localization.UWPAppsTitle
- $ButtonRestore.Content = $Localization.Restore
- # Extract the localized "Select all" string from shell32.dll
- $TextBlockSelectAll.Text = [WinAPI.GetStrings]::GetString(31276)
-
- $ButtonRestore.Add_Click({ButtonRestoreClick})
- $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
- #endregion Variables
-
- #region Functions
- function Get-AppxManifest
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- # You cannot retrieve packages using -PackageTypeFilter Bundle, otherwise you won't get the InstallLocation attribute. It can be retrieved only by comparing with $Bundles
- $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
- $AppxPackages = @(Get-AppxPackage -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"} | Where-Object -FilterScript {$_.Name -in $Bundles})
-
- # The Bundle packages contains no Microsoft Teams
- if (Get-AppxPackage -Name MSTeams -AllUsers)
- {
- $AppxPackages += Get-AppxPackage -Name MSTeams -AllUsers | Where-Object -FilterScript {$_.PackageUserInformation -match "Staged"}
- }
-
- $PackagesIds = [Windows.Management.Deployment.PackageManager]::new().FindPackages() | Select-Object -Property DisplayName -ExpandProperty Id | Select-Object -Property Name, DisplayName
-
- foreach ($AppxPackage in $AppxPackages)
- {
- $PackageId = $PackagesIds | Where-Object -FilterScript {$_.Name -eq $AppxPackage.Name}
-
- if (-not $PackageId)
- {
- continue
- }
-
- [PSCustomObject]@{
- Name = $AppxPackage.Name
- PackageFullName = $AppxPackage.PackageFullName
- DisplayName = $PackageId.DisplayName
- AppxManifest = "$($AppxPackage.InstallLocation)\AppxManifest.xml"
- }
- }
- }
-
- function Add-Control
- {
- [CmdletBinding()]
- param
- (
- [Parameter(
- Mandatory = $true,
- ValueFromPipeline = $true
- )]
- [ValidateNotNull()]
- [PSCustomObject[]]
- $Packages
- )
-
- process
- {
- foreach ($Package in $Packages)
- {
- $CheckBox = New-Object -TypeName System.Windows.Controls.CheckBox
- $CheckBox.Tag = $Package.AppxManifest
-
- $TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
-
- if ($Package.DisplayName)
- {
- $TextBlock.Text = $Package.DisplayName
- }
- else
- {
- $TextBlock.Text = $Package.Name
- }
-
- $StackPanel = New-Object -TypeName System.Windows.Controls.StackPanel
- $StackPanel.Children.Add($CheckBox) | Out-Null
- $StackPanel.Children.Add($TextBlock) | Out-Null
-
- $PanelContainer.Children.Add($StackPanel) | Out-Null
-
- $CheckBox.IsChecked = $true
- $PackagesToRestore.Add($Package.AppxManifest)
-
- $CheckBox.Add_Click({CheckBoxClick})
- }
- }
- }
-
- function ButtonRestoreClick
- {
- Write-Information -MessageData "" -InformationAction Continue
- # Extract the localized "Please wait..." string from shell32.dll
- Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose
-
- $Window.Close() | Out-Null
-
- $Parameters = @{
- Register = $true
- ForceApplicationShutdown = $true
- ForceUpdateFromAnyVersion = $true
- DisableDevelopmentMode = $true
- Verbose = $true
- }
- $PackagesToRestore | Add-AppxPackage @Parameters
- }
-
- function CheckBoxClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Add($CheckBox.Tag) | Out-Null
- }
- else
- {
- $PackagesToRestore.Remove($CheckBox.Tag)
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function CheckBoxSelectAllClick
- {
- $CheckBox = $_.Source
-
- if ($CheckBox.IsChecked)
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $true
- $PackagesToRestore.Add($Item.Tag)
- }
- }
- }
- else
- {
- $PackagesToRestore.Clear()
-
- foreach ($Item in $PanelContainer.Children.Children)
- {
- if ($Item -is [System.Windows.Controls.CheckBox])
- {
- $Item.IsChecked = $false
- }
- }
- }
-
- ButtonRestoreSetIsEnabled
- }
-
- function ButtonRestoreSetIsEnabled
- {
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
- else
- {
- $ButtonRestore.IsEnabled = $false
- }
- }
- #endregion Functions
-
- $PackagesToRestore = [Collections.Generic.List[string]]::new()
- $AppXPackages = Get-AppxManifest
- $AppXPackages | Add-Control
-
- if ($AppxPackages.Count -eq 0)
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.NoData -Verbose
- }
- else
- {
- Write-Information -MessageData "" -InformationAction Continue
- Write-Verbose -Message $Localization.DialogBoxOpening -Verbose
-
- #region Sendkey function
- # Emulate the Backspace key sending to prevent the console window to freeze
- Start-Sleep -Milliseconds 500
-
- Add-Type -AssemblyName System.Windows.Forms
-
- Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process {
- # Show window, if minimized
- [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
-
- Start-Sleep -Seconds 1
-
- # Force move the console window to the foreground
- [WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
-
- Start-Sleep -Seconds 1
-
- # Emulate the Backspace key sending to prevent the console window to freeze
- [System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
- }
- #endregion Sendkey function
-
- if ($PackagesToRestore.Count -gt 0)
- {
- $ButtonRestore.IsEnabled = $true
- }
-
- # Force move the WPF form to the foreground
- $Window.Add_Loaded({$Window.Activate()})
- $Form.ShowDialog() | Out-Null
- }
-}
-
<#
.SYNOPSIS
Cortana autostarting
@@ -14239,7 +13639,7 @@ function UseStoreOpenWith
)
# Remove all policies in order to make changes visible in UI only if it's possible
- Remove-ItemProperty -Path HKLM:\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
+ Remove-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Type CLEAR
switch ($PSCmdlet.ParameterSetName)
diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1
index 0b58ecea..b14d51a5 100644
--- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1
+++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1
@@ -591,7 +591,7 @@ NavigationPaneExpand -Disable
# OneDrive -Install
# Install OneDrive 64-bit all users to %ProgramFiles% depending which installer is triggered
-# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от от того, как запускается инсталлятор
+# Установить OneDrive 64-бит для всех пользователей в %ProgramFiles% в зависимости от того, как запускается инсталлятор
# OneDrive -Install -AllUsers
#endregion OneDrive
@@ -630,14 +630,6 @@ Hibernation -Disable
# Включить режим гибернации (значение по умолчанию)
# Hibernation -Enable
-# Change the %TEMP% environment variable path to %SystemDrive%\Temp
-# Изменить путь переменной среды для %TEMP% на %SystemDrive%\Temp
-# TempFolder -SystemDrive
-
-# Change %TEMP% environment variable path to %LOCALAPPDATA%\Temp (default value)
-# Изменить путь переменной среды для %TEMP% на %LOCALAPPDATA%\Temp (значение по умолчанию)
-# TempFolder -Default
-
# Disable the Windows 260 characters path limit
# Отключить ограничение Windows на 260 символов в пути
Win32LongPathLimit -Disable
@@ -817,7 +809,7 @@ LatestInstalled.NET -Enable
The function will be applied only if the preset is configured to remove the OneDrive application, or the app was already uninstalled
Otherwise the backup functionality for the "Desktop" and "Pictures" folders in OneDrive breaks
- Сохранять скриншоты по нажатию Win+PrtScr на рабочий столе
+ Сохранять скриншоты по нажатию Win+PrtScr на рабочий стол
Функция будет применена только в случае, если в пресете настроено удаление приложения OneDrive или приложение уже удалено,
иначе в OneDrive ломается функционал резервного копирования для папок "Рабочий стол" и "Изображения"
#>
@@ -1066,24 +1058,13 @@ StartLayout -ShowMorePins
#region UWP apps
<#
- Uninstall UWP apps using the pop-up dialog box
+ Uninstall UWP apps for all users using the pop-up dialog box
If the "For All Users" is checked apps packages will not be installed for new users
- The "ForAllUsers" argument sets a checkbox to unistall packages for all users
- Удалить UWP-приложения, используя всплывающее диалоговое окно
+ Удалить UWP-приложения для всех пользователей, используя всплывающее диалоговое окно
Пакеты приложений не будут установлены для новых пользователей, если отмечена галочка "Для всех пользователей"
- Аргумент "ForAllUsers" устанавливает галочку для удаления пакетов для всех пользователей
-#>
-UninstallUWPApps
-
-<#
- Restore the default UWP apps using the pop-up dialog box
- UWP apps can be restored only if they were uninstalled only for the current user
-
- Восстановить стандартные UWP-приложения, используя всплывающее диалоговое окно
- UWP-приложения могут быть восстановлены, только если они были удалены для текущего пользователя
#>
-# RestoreUWPApps
+# UninstallUWPApps -ForAllUsers
# Disable Cortana autostarting
# Выключить автозагрузку Кортана