Browse Source

v4.5.6 03.08.2020

## Windows 10 2004 | 1903/1909 Version

## Updated

- Added "Turn on Windows 10 20H2 new Start style" section. The new Start style described [here](https://www.windowslatest.com/2020/08/02/windows-10-2004-gets-20h2-features/);
- Added "Install the Windows Subsystem for Linux (WSL)" section;
- Added new package "Microsoft.Photos.MediaEngineDLC" to the $UncheckedAppxPackages variable in "Uninstall UWP apps" section;
- region Edge removed (only for 1903/1909 Version);
- Comments;
- Minor changes.

## Windows 10 LTSC Enterprise 2019 Version

## Updated

- Minor changes.

## Версия для Windows 10 2004 | 1903/1909

## Обновлено

- Добавлен раздел "Включить новый стиль Пуск от Windows 10 20H2". Новый стиль Пуск описан [здесь](https://www.windowslatest.com/2020/08/02/windows-10-2004-gets-20h2-features/);
- Добавлен раздел "Установить подсистему Windows для Linux (WSL);
- Добавлен новый пакет "Microsoft.Photos.MediaEngineDLC" в переменную $UncheckedAppxPackages в разделе "Удалить UWP-приложения";
- region Edge удален (только для версии 1903/1909);
- Комментарии;
- Незначительные изменения.

## Версия для Windows 10 LTSC Enterprise 2019

## Обновлено

- Незначительные изменения.
pull/59/head 4.5.6
Dmitry Nefedov 4 years ago
committed by GitHub
parent
commit
95265e1d0b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 482
      LTSC.ps1
  2. 251
      Win 10 1903-1909.ps1
  3. 333
      Win 10 2004.ps1

482
LTSC.ps1

@ -1,9 +1,9 @@
<#
<#
.SYNOPSIS
"Windows 10 Setup Script" is a set of tweaks for OS fine-tuning and automating the routine tasks
Version: v4.4.5
Date: 02.07.2020
Version: v4.4.6
Date: 03.08.2020
Copyright (c) 2020 farag & oZ-Zo
Thanks to all http://forum.ru-board.com members involved
@ -1086,8 +1086,8 @@ function UserShellFolder
Name = "KnownFolders"
Language = "CSharp"
MemberDefinition = @"
[DllImport("shell32.dll")]
public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path);
[DllImport("shell32.dll")]
public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path);
"@
}
if (-not ("WinAPI.KnownFolders" -as [type]))
@ -1292,13 +1292,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Рабочий стол`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Desktop folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1338,13 +1338,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Документы`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Documents folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1384,13 +1384,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Загрузки`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Downloads folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1430,13 +1430,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Музыка`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Music folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1477,13 +1477,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Изображения`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Pictures folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1523,13 +1523,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Видео`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Videos folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1617,10 +1617,6 @@ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" -Name Autorun -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" -Name Autorun -PropertyType DWord -Value 0 -Force
# Turn on automatically save my restartable apps when sign out and restart them after sign in
# Автоматически сохранять мои перезапускаемые приложения при выходе из системы и перезапустить их после выхода
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name RestartApps -Value 1 -Force
# Turn on network discovery and file and printers sharing if device is not domain-joined
# Включить сетевое обнаружение и общий доступ к файлам и принтерам, если устройство не присоединенно к домену
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
@ -1628,6 +1624,10 @@ if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
Get-NetFirewallRule -Group "@FirewallAPI.dll,-32752", "@FirewallAPI.dll,-28502" | Set-NetFirewallRule -Profile Private -Enabled True
Set-NetConnectionProfile -NetworkCategory Private
}
# Automatically adjust active hours for me based on daily usage
# Автоматически изменять период активности для этого устройства на основе действий
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name SmartActiveHoursState -PropertyType DWord -Value 1 -Force
#endregion System
#region Start menu
@ -1707,51 +1707,55 @@ if (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScrip
$Options = "&Add", "&Skip"
}
$DefaultChoice = 1
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
do
{
"0"
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
{
if (-not (Test-Path -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences))
"0"
{
New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force
}
if (-not (Test-Path -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences))
{
New-Item -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Force
}
Add-Type -AssemblyName System.Windows.Forms
$OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
if ($RU)
{
$OpenFileDialog.Filter = "*.exe|*.exe|Все файлы (*.*)|*.*"
}
else
{
$OpenFileDialog.Filter = "*.exe|*.exe|All Files (*.*)|*.*"
}
$OpenFileDialog.InitialDirectory = "${env:ProgramFiles(x86)}"
$OpenFileDialog.Multiselect = $false
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($tmp)
if ($OpenFileDialog.FileName)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force
}
$Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
}
"1"
{
if ($RU)
{
Write-Verbose -Message "Пропущено" -Verbose
Add-Type -AssemblyName System.Windows.Forms
$OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
if ($RU)
{
$OpenFileDialog.Filter = "*.exe|*.exe|Все файлы (*.*)|*.*"
}
else
{
$OpenFileDialog.Filter = "*.exe|*.exe|All Files (*.*)|*.*"
}
$OpenFileDialog.InitialDirectory = "${env:ProgramFiles(x86)}"
$OpenFileDialog.Multiselect = $false
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($tmp)
if ($OpenFileDialog.FileName)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force
}
$Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
}
else
"1"
{
Write-Verbose -Message "Skipped" -Verbose
if ($RU)
{
Write-Verbose -Message "Пропущено" -Verbose
}
else
{
Write-Verbose -Message "Skipped" -Verbose
}
}
}
}
until ($Result -eq 1)
}
#endregion Gaming
@ -1802,31 +1806,31 @@ $Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
if ($PSUICulture -eq "ru-RU")
{
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Очистка неиспользуемых файлов и обновлений Windows начнется через минуту</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Хорошо" arguments="later"/>
</actions>
</toast>
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Очистка неиспользуемых файлов и обновлений Windows начнется через минуту</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Хорошо" arguments="later"/>
</actions>
</toast>
"@
}
else
{
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Cleaning up unused Windows files and updates start in a minute</text>
</binding>
</visual>
<actions>
<action activationType="background" content="OK" arguments="later"/>
</actions>
</toast>
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Cleaning up unused Windows files and updates start in a minute</text>
</binding>
</visual>
<actions>
<action activationType="background" content="OK" arguments="later"/>
</actions>
</toast>
"@
}
@ -1871,8 +1875,8 @@ function MinimizeWindow
Name = "Win32ShowWindowAsync"
Language = "CSharp"
MemberDefinition = @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@
}
if (-not ("WinAPI.Win32ShowWindowAsync" -as [type]))
@ -2021,46 +2025,49 @@ else
$Options = "&Add a protected folder", "&Skip"
}
$DefaultChoice = 1
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
do
{
"0"
{
Add-Type -AssemblyName System.Windows.Forms
$FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog
if ($RU)
{
$FolderBrowserDialog.Description = "Выберите папку"
}
else
{
$FolderBrowserDialog.Description = "Select a folder"
}
$FolderBrowserDialog.RootFolder = "MyComputer"
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($tmp)
if ($FolderBrowserDialog.SelectedPath)
{
Set-MpPreference -EnableControlledFolderAccess Enabled
Add-MpPreference -ControlledFolderAccessProtectedFolders $FolderBrowserDialog.SelectedPath -Force
}
$Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
}
"1"
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
{
if ($RU)
"0"
{
Write-Verbose -Message "Пропущено" -Verbose
Add-Type -AssemblyName System.Windows.Forms
$FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog
if ($RU)
{
$FolderBrowserDialog.Description = "Выберите папку"
}
else
{
$FolderBrowserDialog.Description = "Select a folder"
}
$FolderBrowserDialog.RootFolder = "MyComputer"
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($tmp)
if ($FolderBrowserDialog.SelectedPath)
{
Set-MpPreference -EnableControlledFolderAccess Enabled
Add-MpPreference -ControlledFolderAccessProtectedFolders $FolderBrowserDialog.SelectedPath -Force
}
}
else
"1"
{
Write-Verbose -Message "Skipped" -Verbose
if ($RU)
{
Write-Verbose -Message "Пропущено" -Verbose
}
else
{
Write-Verbose -Message "Skipped" -Verbose
}
}
}
}
until ($Result -eq 1)
# Allow an app through Controlled folder access
# Разрешить работу приложения через контролируемый доступ к папкам
@ -2079,46 +2086,49 @@ if ((Get-MpPreference).EnableControlledFolderAccess -eq 1)
$Options = "&Add a protected folder", "&Skip"
}
$DefaultChoice = 1
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
do
{
"0"
{
Add-Type -AssemblyName System.Windows.Forms
$OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
if ($RU)
{
$OpenFileDialog.Filter = "*.exe|*.exe|Все файлы (*.*)|*.*"
}
else
{
$OpenFileDialog.Filter = "*.exe|*.exe|All Files (*.*)|*.*"
}
$OpenFileDialog.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$OpenFileDialog.Multiselect = $false
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($tmp)
if ($OpenFileDialog.FileName)
{
Add-MpPreference -ControlledFolderAccessAllowedApplications $OpenFileDialog.FileName -Force
}
$Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
}
"1"
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
{
if ($RU)
"0"
{
Write-Verbose -Message "Пропущено" -Verbose
Add-Type -AssemblyName System.Windows.Forms
$OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
if ($RU)
{
$OpenFileDialog.Filter = "*.exe|*.exe|Все файлы (*.*)|*.*"
}
else
{
$OpenFileDialog.Filter = "*.exe|*.exe|All Files (*.*)|*.*"
}
$OpenFileDialog.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$OpenFileDialog.Multiselect = $false
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($tmp)
if ($OpenFileDialog.FileName)
{
Add-MpPreference -ControlledFolderAccessAllowedApplications $OpenFileDialog.FileName -Force
}
}
else
"1"
{
Write-Verbose -Message "Skipped" -Verbose
if ($RU)
{
Write-Verbose -Message "Пропущено" -Verbose
}
else
{
Write-Verbose -Message "Skipped" -Verbose
}
}
}
}
until ($Result -eq 1)
}
# Add exclusion folder from Windows Defender Antivirus scanning
@ -2136,45 +2146,48 @@ else
$Options = "&Exclude folder", "&Skip"
}
$DefaultChoice = 1
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
do
{
"0"
{
Add-Type -AssemblyName System.Windows.Forms
$FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog
if ($RU)
{
$FolderBrowserDialog.Description = "Выберите папку"
}
else
{
$FolderBrowserDialog.Description = "Select a folder"
}
$FolderBrowserDialog.RootFolder = "MyComputer"
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($tmp)
if ($FolderBrowserDialog.SelectedPath)
{
Add-MpPreference -ExclusionPath $FolderBrowserDialog.SelectedPath -Force
}
$Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
}
"1"
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
{
if ($RU)
"0"
{
Write-Verbose -Message "Пропущено" -Verbose
Add-Type -AssemblyName System.Windows.Forms
$FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog
if ($RU)
{
$FolderBrowserDialog.Description = "Выберите папку"
}
else
{
$FolderBrowserDialog.Description = "Select a folder"
}
$FolderBrowserDialog.RootFolder = "MyComputer"
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($tmp)
if ($FolderBrowserDialog.SelectedPath)
{
Add-MpPreference -ExclusionPath $FolderBrowserDialog.SelectedPath -Force
}
}
else
"1"
{
Write-Verbose -Message "Skipped" -Verbose
if ($RU)
{
Write-Verbose -Message "Пропущено" -Verbose
}
else
{
Write-Verbose -Message "Skipped" -Verbose
}
}
}
}
until ($Result -eq 1)
# Add exclusion file from Windows Defender Antivirus scanning
# Добавить файл в список исключений сканирования Windows Defender
@ -2191,46 +2204,49 @@ else
$Options = "&Exclude file", "&Skip"
}
$DefaultChoice = 1
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
do
{
"0"
{
Add-Type -AssemblyName System.Windows.Forms
$OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
if ($RU)
{
$OpenFileDialog.Filter = "Все файлы (*.*)|*.*"
}
else
{
$OpenFileDialog.Filter = "All Files (*.*)|*.*"
}
$OpenFileDialog.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$OpenFileDialog.Multiselect = $false
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($tmp)
if ($OpenFileDialog.FileName)
{
Add-MpPreference -ExclusionPath $OpenFileDialog.FileName -Force
}
$Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
}
"1"
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
{
if ($RU)
"0"
{
Write-Verbose -Message "Пропущено" -Verbose
Add-Type -AssemblyName System.Windows.Forms
$OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
if ($RU)
{
$OpenFileDialog.Filter = "Все файлы (*.*)|*.*"
}
else
{
$OpenFileDialog.Filter = "All Files (*.*)|*.*"
}
$OpenFileDialog.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$OpenFileDialog.Multiselect = $false
# Focus on open file dialog
# Перевести фокус на диалог открытия файла
$tmp = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($tmp)
if ($OpenFileDialog.FileName)
{
Add-MpPreference -ExclusionPath $OpenFileDialog.FileName -Force
}
}
else
"1"
{
Write-Verbose -Message "Skipped" -Verbose
if ($RU)
{
Write-Verbose -Message "Пропущено" -Verbose
}
else
{
Write-Verbose -Message "Skipped" -Verbose
}
}
}
}
until ($Result -eq 1)
# Turn on Windows Defender Exploit Guard network protection
# Включить защиту сети в Windows Defender Exploit Guard
@ -2276,10 +2292,6 @@ In order this feature to work events auditing and command line in process creati
Создать настаиваемое представление "Создание процесса" в Просмотре событий
Необходимо включить аудит событий и командную строку в событиях создания процесса, чтобы работала данная опция
#>
if ($RU)
{
$OutputEncoding = [System.Console]::OutputEncoding = [System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
}
$XML = @"
<ViewerConfig>
<QueryConfig>
@ -2359,7 +2371,7 @@ if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Comm
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Force
}
$Value = "{0}" -f 'cmd /c DISM.exe /Online /Add-Package /PackagePath:"%1" /NoRestart & pause'
$Value = "{0}" -f "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Name "(Default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name HasLUAShield -PropertyType String -Value "" -Force
@ -2452,34 +2464,34 @@ $UpdateExplorer = @{
Name = "UpdateExplorer"
Language = "CSharp"
MemberDefinition = @"
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void Refresh()
{
// Update desktop icons
// Обновить иконки рабочего стола
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
// Обновить переменные среды
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
// Обновить панель задач
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
private static readonly IntPtr hWnd = new IntPtr(65535);
private const int Msg = 273;
// Virtual key ID of the F5 in File Explorer
// Виртуальный код клавиши F5 в проводнике
private static readonly UIntPtr UIntPtr = new UIntPtr(41504);
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void Refresh()
{
// Update desktop icons
// Обновить иконки рабочего стола
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
// Обновить переменные среды
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
// Обновить панель задач
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
private static readonly IntPtr hWnd = new IntPtr(65535);
private const int Msg = 273;
// Virtual key ID of the F5 in File Explorer
// Виртуальный код клавиши F5 в проводнике
private static readonly UIntPtr UIntPtr = new UIntPtr(41504);
[DllImport("user32.dll", SetLastError=true)]
public static extern int PostMessageW(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
@ -2524,4 +2536,4 @@ if ($Error)
}
}
} | Sort-Object -Property Line | Format-Table -AutoSize -Wrap | Out-String).Trim()
}
}

251
Win 10 1903-1909.ps1

@ -2,8 +2,8 @@
.SYNOPSIS
"Windows 10 Setup Script" is a set of tweaks for OS fine-tuning and automating the routine tasks
Version: v4.4.6
Date: 07.07.2020
Version: v4.4.7
Date: 03.08.2020
Copyright (c) 2020 farag & oZ-Zo
Thanks to all http://forum.ru-board.com members involved
@ -493,18 +493,18 @@ $Signature = @{
Name = "GetStr"
Language = "CSharp"
MemberDefinition = @"
// https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/8#issue-227159084
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
public static string GetString(uint strId)
{
IntPtr intPtr = GetModuleHandle("shell32.dll");
StringBuilder sb = new StringBuilder(255);
LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString();
}
// https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/8#issue-227159084
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
public static string GetString(uint strId)
{
IntPtr intPtr = GetModuleHandle("shell32.dll");
StringBuilder sb = new StringBuilder(255);
LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString();
}
"@
}
if (-not ("WinAPI.GetStr" -as [type]))
@ -650,11 +650,6 @@ Stop-Process -Name Taskmgr
$preferences.Preferences[28] = 0
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager -Name Preferences -PropertyType Binary -Value $preferences.Preferences -Force
# Remove Microsoft Edge shortcut from the Desktop
# Удалить ярлык Microsoft Edge с рабочего стола
$DesktopFolder = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop
Remove-Item -Path "$DesktopFolder\Microsoft Edge.lnk" -Force -ErrorAction Ignore
# Show a notification when your PC requires a restart to finish updating
# Показывать уведомление, когда компьютеру требуется перезагрузка для завершения обновления
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name RestartNotificationsAllowed2 -PropertyType DWord -Value 1 -Force
@ -666,10 +661,6 @@ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer
# Use the PrtScn button to open screen snipping
# Использовать кнопку PRINT SCREEN, чтобы запустить функцию создания фрагмента экрана
New-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name PrintScreenKeyForSnippingEnabled -PropertyType DWord -Value 1 -Force
# Automatically adjust active hours for me based on daily usage
# Автоматически изменять период активности для этого устройства на основе действий
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name SmartActiveHoursState -PropertyType DWord -Value 1 -Force
#endregion UI & Personalization
#region OneDrive
@ -1322,8 +1313,8 @@ function UserShellFolder
Name = "KnownFolders"
Language = "CSharp"
MemberDefinition = @"
[DllImport("shell32.dll")]
public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path);
[DllImport("shell32.dll")]
public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path);
"@
}
if (-not ("WinAPI.KnownFolders" -as [type]))
@ -1528,13 +1519,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Рабочий стол`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Desktop folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1574,13 +1565,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Документы`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Documents folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1620,13 +1611,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Загрузки`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Downloads folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1666,13 +1657,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Музыка`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Music folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1713,13 +1704,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Изображения`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Pictures folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1759,13 +1750,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Видео`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Videos folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1867,7 +1858,6 @@ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" -Name Autorun -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" -Name Autorun -PropertyType DWord -Value 0 -Force
# Turn on network discovery and file and printers sharing if device is not domain-joined
# Включить сетевое обнаружение и общий доступ к файлам и принтерам, если устройство не присоединенно к домену
if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
@ -1875,6 +1865,10 @@ if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
Get-NetFirewallRule -Group "@FirewallAPI.dll,-32752", "@FirewallAPI.dll,-28502" | Set-NetFirewallRule -Profile Private -Enabled True
Set-NetConnectionProfile -NetworkCategory Private
}
# Automatically adjust active hours for me based on daily usage
# Автоматически изменять период активности для этого устройства на основе действий
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name SmartActiveHoursState -PropertyType DWord -Value 1 -Force
#endregion System
#region Start menu
@ -1939,19 +1933,19 @@ switch ($Result)
"0"
{
$StartMenuLayout = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@
$StartMenuLayoutPath = "$env:TEMP\StartMenuLayout.xml"
# Saving StartMenuLayout.xml in UTF-8 encoding
# Сохраняем StartMenuLayout.xml в кодировке UTF-8
Set-Content -Value (New-Object System.Text.UTF8Encoding).GetBytes($StartMenuLayout) -Encoding Byte -Path $StartMenuLayoutPath -Force
Set-Content -Path $StartMenuLayoutPath -Value (New-Object System.Text.UTF8Encoding).GetBytes($StartMenuLayout) -Encoding Byte -Force
# Temporarily disable changing Start layout
# Временно выключаем возможность редактировать начальный экран
@ -2050,9 +2044,9 @@ if ($syspin -eq $true)
if (Test-Path -Path "$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk")
{
$Arguments = @"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk" "51201"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
}
else
{
@ -2064,7 +2058,7 @@ if ($syspin -eq $true)
$Shortcut.Save()
$Arguments = @"
"$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" "51201"
"$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
Remove-Item -Path "$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" -Force
@ -2094,7 +2088,7 @@ if ($syspin -eq $true)
# Пауза на 3 с, иначе ярлык "Устройства и принтеры" не будет отображаться в меню "Пуск"
Start-Sleep -Seconds 3
$Arguments = @"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\$DevicesAndPrintersLocalizedName.lnk" "51201"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\$DevicesAndPrintersLocalizedName.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
@ -2109,7 +2103,7 @@ if ($syspin -eq $true)
Write-Verbose -Message "`"Command Prompt`" shortcut is being pinned to Start" -Verbose
}
$Arguments = @"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\Command Prompt.lnk" "51201"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\Command Prompt.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
@ -2119,28 +2113,6 @@ if ($syspin -eq $true)
}
#endregion Start menu
#region Edge
# Do not allow Microsoft Edge to start and load the Start and New Tab page at Windows startup and each time Microsoft Edge is closed
# Не разрешать Edge запускать и загружать страницу при загрузке Windows и каждый раз при закрытии Edge
if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader))
{
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader -Name AllowTabPreloading -PropertyType DWord -Value 0 -Force
# Do not allow Microsoft Edge to pre-launch at Windows startup, when the system is idle, and each time Microsoft Edge is closed
# Не разрешать предварительный запуск Edge при загрузке Windows, когда система простаивает, и каждый раз при закрытии Edge
if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main))
{
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main -Force
}
New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main -Name AllowPrelaunch -PropertyType DWord -Value 0 -Force
# Turn off creation of an Edge shortcut on the desktop for each user profile
# Отключить создание ярлыка Edge на рабочем столе для каждого профиля пользователя пользователя
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name DisableEdgeDesktopShortcutCreation -PropertyType DWord -Value 1 -Force
#endregion Edge
#region UWP apps
<#
Uninstall UWP apps
@ -2181,6 +2153,7 @@ $UncheckedAppxPackages = @(
# Photos and Video Editor
# Фотографии и Видеоредактор
"Microsoft.Windows.Photos"
"Microsoft.Photos.MediaEngineDLC"
# Calculator
# Калькулятор
"Microsoft.WindowsCalculator"
@ -2564,31 +2537,31 @@ $Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
if ($PSUICulture -eq "ru-RU")
{
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Очистка неиспользуемых файлов и обновлений Windows начнется через минуту</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Хорошо" arguments="later"/>
</actions>
</toast>
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Очистка неиспользуемых файлов и обновлений Windows начнется через минуту</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Хорошо" arguments="later"/>
</actions>
</toast>
"@
}
else
{
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Cleaning up unused Windows files and updates start in a minute</text>
</binding>
</visual>
<actions>
<action activationType="background" content="OK" arguments="later"/>
</actions>
</toast>
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Cleaning up unused Windows files and updates start in a minute</text>
</binding>
</visual>
<actions>
<action activationType="background" content="OK" arguments="later"/>
</actions>
</toast>
"@
}
@ -2633,8 +2606,8 @@ function MinimizeWindow
Name = "Win32ShowWindowAsync"
Language = "CSharp"
MemberDefinition = @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@
}
if (-not ("WinAPI.Win32ShowWindowAsync" -as [type]))
@ -3106,16 +3079,6 @@ New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Scri
# Отключить SmartScreen для приложений и файлов
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name SmartScreenEnabled -PropertyType String -Value Off -Force
# Turn off Windows Defender SmartScreen for Microsoft Edge
# Отключить Windows Defender SmartScreen в Microsoft Edge
$edge = (Get-AppxPackage -Name Microsoft.MicrosoftEdge).PackageFamilyName
if (-not (Test-Path -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter"))
{
New-Item -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Force
}
New-ItemProperty -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name EnabledV9 -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name PreventOverride -PropertyType DWord -Value 0 -Force
# Turn off Windows Script Host
# Отключить Windows Script Host
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -PropertyType DWord -Value 0 -Force
@ -3139,7 +3102,7 @@ if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Comm
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Force
}
$Value = "{0}" -f 'cmd /c DISM.exe /Online /Add-Package /PackagePath:"%1" /NoRestart & pause'
$Value = "{0}" -f "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Name "(Default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name HasLUAShield -PropertyType String -Value "" -Force
@ -3242,43 +3205,43 @@ $UpdateExplorer = @{
Name = "UpdateExplorer"
Language = "CSharp"
MemberDefinition = @"
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void Refresh()
{
// Update desktop icons
// Обновить иконки рабочего стола
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
// Обновить переменные среды
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
// Обновить панель задач
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
private static readonly IntPtr hWnd = new IntPtr(65535);
private const int Msg = 273;
// Virtual key ID of the F5 in File Explorer
// Виртуальный код клавиши F5 в проводнике
private static readonly UIntPtr UIntPtr = new UIntPtr(41504);
[DllImport("user32.dll", SetLastError=true)]
public static extern int PostMessageW(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
public static void PostMessage()
{
// F5 pressing simulation to refresh the desktop
// Симуляция нажатия F5 для обновления рабочего стола
PostMessageW(hWnd, Msg, UIntPtr, IntPtr.Zero);
}
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void Refresh()
{
// Update desktop icons
// Обновить иконки рабочего стола
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
// Обновить переменные среды
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
// Обновить панель задач
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
private static readonly IntPtr hWnd = new IntPtr(65535);
private const int Msg = 273;
// Virtual key ID of the F5 in File Explorer
// Виртуальный код клавиши F5 в проводнике
private static readonly UIntPtr UIntPtr = new UIntPtr(41504);
[DllImport("user32.dll", SetLastError=true)]
public static extern int PostMessageW(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
public static void PostMessage()
{
// F5 pressing simulation to refresh the desktop
// Симуляция нажатия F5 для обновления рабочего стола
PostMessageW(hWnd, Msg, UIntPtr, IntPtr.Zero);
}
"@
}
if (-not ("WinAPI.UpdateExplorer" -as [type]))

333
Win 10 2004.ps1

@ -2,8 +2,8 @@
.SYNOPSIS
"Windows 10 Setup Script" is a set of tweaks for OS fine-tuning and automating the routine tasks
Version: v4.5.5
Date: 07.07.2020
Version: v4.5.6
Date: 03.08.2020
Copyright (c) 2020 farag & oZ-Zo
Thanks to all http://forum.ru-board.com members involved
@ -493,18 +493,18 @@ $Signature = @{
Name = "GetStr"
Language = "CSharp"
MemberDefinition = @"
// https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/8#issue-227159084
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
public static string GetString(uint strId)
{
IntPtr intPtr = GetModuleHandle("shell32.dll");
StringBuilder sb = new StringBuilder(255);
LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString();
}
// https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/8#issue-227159084
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern int LoadString(IntPtr hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
public static string GetString(uint strId)
{
IntPtr intPtr = GetModuleHandle("shell32.dll");
StringBuilder sb = new StringBuilder(255);
LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString();
}
"@
}
if (-not ("WinAPI.GetStr" -as [type]))
@ -662,9 +662,17 @@ New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer
# Использовать кнопку PRINT SCREEN, чтобы запустить функцию создания фрагмента экрана
New-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name PrintScreenKeyForSnippingEnabled -PropertyType DWord -Value 1 -Force
# Automatically adjust active hours for me based on daily usage
# Автоматически изменять период активности для этого устройства на основе действий
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name SmartActiveHoursState -PropertyType DWord -Value 1 -Force
# Turn on Windows 10 20H2 new Start style
# Включить новый стиль Пуска как в Windows 10 20H2
if (Get-HotFix -Id KB4568831 -ErrorAction Ignore)
{
if (-not (Test-Path -Path HKLM:\SYSTEM\CurrentControlSet\Control\FeatureManagement\Overrides\0\2093230218s))
{
New-Item -Path HKLM:\SYSTEM\CurrentControlSet\Control\FeatureManagement\Overrides\0\2093230218 -Force
}
New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\FeatureManagement\Overrides\0\2093230218 -Name EnabledState -PropertyType DWORD -Value 2 -Force
New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\FeatureManagement\Overrides\0\2093230218 -Name EnabledStateOptions -PropertyType DWORD -Value 0 -Force
}
#endregion UI & Personalization
#region OneDrive
@ -824,6 +832,7 @@ New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Capabilit
# Change %TEMP% environment variable path to the %SystemDrive%\Temp
# Изменить путь переменной среды для %TEMP% на %SystemDrive%\Temp
# https://github.com/microsoft/WSL/issues/5437
if (-not (Test-Path -Path $env:SystemDrive\Temp))
{
New-Item -Path $env:SystemDrive\Temp -ItemType Directory -Force
@ -918,6 +927,115 @@ $WindowsOptionalFeatures = @(
)
Disable-WindowsOptionalFeature -Online -FeatureName $WindowsOptionalFeatures -NoRestart
# Install the Windows Subsystem for Linux (WSL)
# Установить подсистему Windows для Linux (WSL)
if ($RU)
{
$Title = "Windows Subsystem for Linux"
$Message = "Чтобы установить Windows Subsystem for Linux, введите необходимую букву"
$Options = "&Установить", "&Пропустить"
}
else
{
$Title = "Windows Subsystem for Linux"
$Message = "To install the Windows Subsystem for Linux enter the required letter"
$Options = "&Install", "&Skip"
}
$DefaultChoice = 1
$Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice)
switch ($Result)
{
"0"
{
# Enable the Windows Subsystem for Linux
# Включить подсистему Windows для Linux
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart
# Enable Virtual Machine Platform
# Включить поддержку платформы для виртуальных машин
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
# Downloading the Linux kernel update package
# Скачиваем пакет обновления ядра Linux
try
{
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if ((Invoke-WebRequest -Uri https://www.google.com -UseBasicParsing -DisableKeepAlive -Method Head).StatusDescription)
{
$Parameters = @{
Uri = "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
OutFile = "$PSScriptRoot\wsl_update_x64.msi"
Verbose = [switch]::Present
}
Invoke-WebRequest @Parameters
Start-Process -FilePath $PSScriptRoot\wsl_update_x64.msi -ArgumentList "/passive" -Wait
Remove-Item -Path $PSScriptRoot\wsl_update_x64.msi -Force
}
}
catch
{
if ($Error.Exception.Status -eq "NameResolutionFailure")
{
if ($RU)
{
Write-Warning -Message "Отсутствует интернет-соединение" -ErrorAction SilentlyContinue
}
else
{
Write-Warning -Message "No Internet connection" -ErrorAction SilentlyContinue
}
}
}
<#
# Comment out only after installing the Windows Subsystem for Linux
# Раскомментируйте только после установки подсистемы Windows для Linux
# Set WSL 2 as your default version. Run the command only after restart
# Установить WSL 2 как версию по умолчанию. Выполните команду только после перезагрузки
wsl --set-default-version 2
# Configuring .wslconfig
# Настраиваем .wslconfig
# https://github.com/microsoft/WSL/issues/5437
if (-not (Test-Path -Path "$env:HOMEPATH\.wslconfig"))
{
$wslconfig = @"
[wsl2]
swap=0
"@
# Saving .wslconfig in UTF-8 encoding
# Сохраняем .wslconfig в кодировке UTF-8
Set-Content -Path "$env:HOMEPATH\.wslconfig" -Value (New-Object System.Text.UTF8Encoding).GetBytes($wslconfig) -Encoding Byte -Force
}
else
{
$String = Get-Content -Path "$env:HOMEPATH\.wslconfig" | Select-String -Pattern "swap=" -SimpleMatch
if ($String)
{
(Get-Content -Path "$env:HOMEPATH\.wslconfig").Replace("swap=1", "swap=0") | Set-Content -Path "$env:HOMEPATH\.wslconfig" -Force
}
else
{
Add-Content -Path "$env:HOMEPATH\.wslconfig" -Value "swap=0" -Force
}
}
#>
}
"1"
{
if ($RU)
{
Write-Verbose -Message "Пропущено" -Verbose
}
else
{
Write-Verbose -Message "Skipped" -Verbose
}
}
}
# Remove Windows capabilities
# Удалить дополнительные компоненты Windows
Add-Type -AssemblyName PresentationCore, PresentationFramework
@ -1328,8 +1446,8 @@ function UserShellFolder
Name = "KnownFolders"
Language = "CSharp"
MemberDefinition = @"
[DllImport("shell32.dll")]
public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path);
[DllImport("shell32.dll")]
public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, IntPtr token, [MarshalAs(UnmanagedType.LPWStr)] string path);
"@
}
if (-not ("WinAPI.KnownFolders" -as [type]))
@ -1534,13 +1652,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Рабочий стол`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Desktop folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1580,13 +1698,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Документы`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Documents folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1626,13 +1744,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Загрузки`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Downloads folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1672,13 +1790,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Музыка`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Music folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1719,13 +1837,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Изображения`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Pictures folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1765,13 +1883,13 @@ $Title = ""
if ($RU)
{
$Message = "Чтобы изменить местоположение папки `"Видео`", введите необходимую букву"
Write-Warning "`nФайлы не будут перенесены"
Write-Warning -Message "`nФайлы не будут перенесены"
$Options = "&Изменить", "&Пропустить"
}
else
{
$Message = "To change the location of the Videos folder enter the required letter"
Write-Warning "`nFiles will not be moved"
Write-Warning -Message "`nFiles will not be moved"
$Options = "&Change", "&Skip"
}
$DefaultChoice = 1
@ -1883,6 +2001,10 @@ if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
Get-NetFirewallRule -Group "@FirewallAPI.dll,-32752", "@FirewallAPI.dll,-28502" | Set-NetFirewallRule -Profile Private -Enabled True
Set-NetConnectionProfile -NetworkCategory Private
}
# Automatically adjust active hours for me based on daily usage
# Автоматически изменять период активности для этого устройства на основе действий
New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name SmartActiveHoursState -PropertyType DWord -Value 1 -Force
#endregion System
#region Start menu
@ -1947,19 +2069,19 @@ switch ($Result)
"0"
{
$StartMenuLayout = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@
$StartMenuLayoutPath = "$env:TEMP\StartMenuLayout.xml"
# Saving StartMenuLayout.xml in UTF-8 encoding
# Сохраняем StartMenuLayout.xml в кодировке UTF-8
Set-Content -Value (New-Object System.Text.UTF8Encoding).GetBytes($StartMenuLayout) -Encoding Byte -Path $StartMenuLayoutPath -Force
Set-Content -Path $StartMenuLayoutPath -Value (New-Object System.Text.UTF8Encoding).GetBytes($StartMenuLayout) -Encoding Byte -Force
# Temporarily disable changing Start layout
# Временно выключаем возможность редактировать начальный экран
@ -2058,9 +2180,9 @@ if ($syspin -eq $true)
if (Test-Path -Path "$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk")
{
$Arguments = @"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk" "51201"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\$ControlPanelLocalizedName.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
}
else
{
@ -2072,7 +2194,7 @@ if ($syspin -eq $true)
$Shortcut.Save()
$Arguments = @"
"$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" "51201"
"$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
Remove-Item -Path "$env:SystemRoot\System32\$ControlPanelLocalizedName.lnk" -Force
@ -2102,7 +2224,7 @@ if ($syspin -eq $true)
# Пауза на 3 с, иначе ярлык "Устройства и принтеры" не будет отображаться в меню "Пуск"
Start-Sleep -Seconds 3
$Arguments = @"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\$DevicesAndPrintersLocalizedName.lnk" "51201"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\$DevicesAndPrintersLocalizedName.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
@ -2117,7 +2239,7 @@ if ($syspin -eq $true)
Write-Verbose -Message "`"Command Prompt`" shortcut is being pinned to Start" -Verbose
}
$Arguments = @"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\Command Prompt.lnk" "51201"
"$env:APPDATA\Microsoft\Windows\Start menu\Programs\System Tools\Command Prompt.lnk" "51201"
"@
Start-Process -FilePath $PSScriptRoot\syspin.exe -WindowStyle Hidden -ArgumentList $Arguments -Wait
@ -2167,6 +2289,7 @@ $UncheckedAppxPackages = @(
# Photos and Video Editor
# Фотографии и Видеоредактор
"Microsoft.Windows.Photos"
"Microsoft.Photos.MediaEngineDLC"
# Calculator
# Калькулятор
"Microsoft.WindowsCalculator"
@ -2584,31 +2707,31 @@ $Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
if ($PSUICulture -eq "ru-RU")
{
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Очистка неиспользуемых файлов и обновлений Windows начнется через минуту</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Хорошо" arguments="later"/>
</actions>
</toast>
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Очистка неиспользуемых файлов и обновлений Windows начнется через минуту</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Хорошо" arguments="later"/>
</actions>
</toast>
"@
}
else
{
[xml]$ToastTemplate = @"
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Cleaning up unused Windows files and updates start in a minute</text>
</binding>
</visual>
<actions>
<action activationType="background" content="OK" arguments="later"/>
</actions>
</toast>
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Cleaning up unused Windows files and updates start in a minute</text>
</binding>
</visual>
<actions>
<action activationType="background" content="OK" arguments="later"/>
</actions>
</toast>
"@
}
@ -2653,8 +2776,8 @@ function MinimizeWindow
Name = "Win32ShowWindowAsync"
Language = "CSharp"
MemberDefinition = @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@
}
if (-not ("WinAPI.Win32ShowWindowAsync" -as [type]))
@ -3149,7 +3272,7 @@ if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Comm
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Force
}
$Value = "{0}" -f 'cmd /c DISM.exe /Online /Add-Package /PackagePath:"%1" /NoRestart & pause'
$Value = "{0}" -f "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Name "(Default)" -PropertyType String -Value $Value -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name HasLUAShield -PropertyType String -Value "" -Force
@ -3269,43 +3392,43 @@ $UpdateExplorer = @{
Name = "UpdateExplorer"
Language = "CSharp"
MemberDefinition = @"
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void Refresh()
{
// Update desktop icons
// Обновить иконки рабочего стола
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
// Обновить переменные среды
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
// Обновить панель задач
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
private static readonly IntPtr hWnd = new IntPtr(65535);
private const int Msg = 273;
// Virtual key ID of the F5 in File Explorer
// Виртуальный код клавиши F5 в проводнике
private static readonly UIntPtr UIntPtr = new UIntPtr(41504);
[DllImport("user32.dll", SetLastError=true)]
public static extern int PostMessageW(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
public static void PostMessage()
{
// F5 pressing simulation to refresh the desktop
// Симуляция нажатия F5 для обновления рабочего стола
PostMessageW(hWnd, Msg, UIntPtr, IntPtr.Zero);
}
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void Refresh()
{
// Update desktop icons
// Обновить иконки рабочего стола
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
// Обновить переменные среды
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
// Обновить панель задач
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
private static readonly IntPtr hWnd = new IntPtr(65535);
private const int Msg = 273;
// Virtual key ID of the F5 in File Explorer
// Виртуальный код клавиши F5 в проводнике
private static readonly UIntPtr UIntPtr = new UIntPtr(41504);
[DllImport("user32.dll", SetLastError=true)]
public static extern int PostMessageW(IntPtr hWnd, uint Msg, UIntPtr wParam, IntPtr lParam);
public static void PostMessage()
{
// F5 pressing simulation to refresh the desktop
// Симуляция нажатия F5 для обновления рабочего стола
PostMessageW(hWnd, Msg, UIntPtr, IntPtr.Zero);
}
"@
}
if (-not ("WinAPI.UpdateExplorer" -as [type]))

Loading…
Cancel
Save