diff --git a/Sophia/LTSC/Functions.ps1 b/Sophia/LTSC/Functions.ps1
index 983c4028..cdeb29ae 100644
--- a/Sophia/LTSC/Functions.ps1
+++ b/Sophia/LTSC/Functions.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
The TAB completion for functions and their arguments
- Version: v5.2.4
- Date: 07.05.2021
+ Version: v5.2.5
+ Date: 17.05.2021
Copyright (c) 2014–2021 farag
Copyright (c) 2019–2021 farag & oZ-Zo
@@ -66,7 +66,7 @@ function Sophia
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.2.4 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2014–2021"
+$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.2.5 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2014–2021"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Sophia.psd1 -PassThru -Force
diff --git a/Sophia/LTSC/Localizations/hu-HU/Sophia.psd1 b/Sophia/LTSC/Localizations/hu-HU/Sophia.psd1
index 4162131a..2e77b61a 100644
--- a/Sophia/LTSC/Localizations/hu-HU/Sophia.psd1
+++ b/Sophia/LTSC/Localizations/hu-HU/Sophia.psd1
@@ -1,4 +1,4 @@
-ConvertFrom-StringData -StringData @'
+ConvertFrom-StringData -StringData @'
UnsupportedOSBitness = A szkript csak a Windows 10 64 bites verziót támogatja
UnsupportedOSBuild = A szkript támogatja a Windows 10 1809 Enterprise LTSC kiadást
UnsupportedRelease = Új verzió érhető el
diff --git a/Sophia/LTSC/Sophia.ps1 b/Sophia/LTSC/Sophia.ps1
index cf8da6ff..0acca441 100644
--- a/Sophia/LTSC/Sophia.ps1
+++ b/Sophia/LTSC/Sophia.ps1
@@ -2,8 +2,8 @@
.SYNOPSIS
Default preset file for "Windows 10 Sophia Script" (LTSC version)
- Version: v5.2.4
- Date: 07.05.2021
+ Version: v5.2.5
+ Date: 17.05.2021
Copyright (c) 2014–2021 farag
Copyright (c) 2019–2021 farag & oZ-Zo
@@ -71,7 +71,7 @@ param
Clear-Host
-$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.2.4 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2014–2021"
+$Host.UI.RawUI.WindowTitle = "Windows 10 Sophia Script for LTSC v5.2.5 | Made with $([char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([char]0x00A9) farag & oz-zo, 2014–2021"
Remove-Module -Name Sophia -Force -ErrorAction Ignore
Import-Module -Name $PSScriptRoot\Sophia.psd1 -PassThru -Force
@@ -107,10 +107,10 @@ if ($Functions)
#region Protection
<#
- Checkings. If you want disable a warning message about whether you've customized the preset file remove the Warning argument
+ Checkings. If you want to disable a warning message about whether you've customized the preset file remove the "-Warning" argument
Please, do not comment out this function
- Проверки
+ Проверки. Чтобы выключить предупреждение о необходимости настройки пресет-файла, удалите аргумент "-Warning"
Пожалуйста, не комментируйте данную функцию
#>
Checkings -Warning
diff --git a/Sophia/LTSC/Sophia.psd1 b/Sophia/LTSC/Sophia.psd1
index 8a249fae..1cbe4d53 100644
Binary files a/Sophia/LTSC/Sophia.psd1 and b/Sophia/LTSC/Sophia.psd1 differ
diff --git a/Sophia/LTSC/Sophia.psm1 b/Sophia/LTSC/Sophia.psm1
index 4e4750f0..2db3aa0e 100644
--- a/Sophia/LTSC/Sophia.psm1
+++ b/Sophia/LTSC/Sophia.psm1
@@ -2,8 +2,8 @@
.SYNOPSIS
"Windows 10 Sophia Script" (LTSC version) is a PowerShell module for Windows 10 fine-tuning and automating the routine tasks
- Version: v5.2.4
- Date: 07.05.2021
+ Version: v5.2.5
+ Date: 17.05.2021
Copyright (c) 2014–2021 farag
Copyright (c) 2019–2021 farag & oZ-Zo
@@ -545,10 +545,11 @@ function ScheduledTasks
MinHeight="450" MinWidth="400"
SizeToContent="Width" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
- FontFamily="Segoe UI" FontSize="12" ShowInTaskbar="False">
+ FontFamily="Candara" FontSize="16" ShowInTaskbar="True">
+
+
+
@@ -572,7 +585,7 @@ function ScheduledTasks
VerticalScrollBarVisibility="Auto">
-
+
'
@@ -708,11 +721,55 @@ function ScheduledTasks
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
+
+ $SetForegroundWindow = @{
+ Namespace = "WinAPI"
+ Name = "ForegroundWindow"
+ Language = "CSharp"
+ MemberDefinition = @"
+[DllImport("user32.dll")]
+public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
+
+[DllImport("user32.dll")]
+[return: MarshalAs(UnmanagedType.Bool)]
+public static extern bool SetForegroundWindow(IntPtr hWnd);
+"@
+ }
+
+ if (-not ("WinAPI.ForegroundWindow" -as [type]))
+ {
+ Add-Type @SetForegroundWindow
+ }
+
+ Get-Process | Where-Object -FilterScript {$_.MainWindowTitle -like "Windows 10 Sophia Script*"} | ForEach-Object -Process {
+ # Show window, if minimized
+ [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
+
+ Start-Sleep -Milliseconds 100
+
+ # Force move the console window to the foreground
+ [WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
+
+ Start-Sleep -Milliseconds 100
+
+ # Emulate the Backspace key sending
+ [System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
+ }
+ #endregion Sendkey function
+
$Window.Add_Loaded({$Tasks | Add-TaskControl})
$Button.Content = $ButtonContent
$Button.Add_Click({& $ButtonAdd_Click})
$Window.Title = $Localization.ScheduledTasks
+
+ # Force move the WPF form to the foreground
+ $Window.Add_Loaded({$Window.Activate()})
$Form.ShowDialog() | Out-Null
}
@@ -3530,10 +3587,11 @@ function WindowsFeatures
MinHeight="450" MinWidth="400"
SizeToContent="Width" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
- FontFamily="Segoe UI" FontSize="12" ShowInTaskbar="False">
+ FontFamily="Candara" FontSize="16" ShowInTaskbar="True">
+
+
+
@@ -3557,7 +3627,7 @@ function WindowsFeatures
VerticalScrollBarVisibility="Auto">
-
+
'
@@ -3701,11 +3771,55 @@ function WindowsFeatures
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
+
+ $SetForegroundWindow = @{
+ Namespace = "WinAPI"
+ Name = "ForegroundWindow"
+ Language = "CSharp"
+ MemberDefinition = @"
+[DllImport("user32.dll")]
+public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
+
+[DllImport("user32.dll")]
+[return: MarshalAs(UnmanagedType.Bool)]
+public static extern bool SetForegroundWindow(IntPtr hWnd);
+"@
+ }
+
+ if (-not ("WinAPI.ForegroundWindow" -as [type]))
+ {
+ Add-Type @SetForegroundWindow
+ }
+
+ Get-Process | Where-Object -FilterScript {$_.MainWindowTitle -like "Windows 10 Sophia Script*"} | ForEach-Object -Process {
+ # Show window, if minimized
+ [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
+
+ Start-Sleep -Milliseconds 100
+
+ # Force move the console window to the foreground
+ [WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
+
+ Start-Sleep -Milliseconds 100
+
+ # Emulate the Backspace key sending
+ [System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
+ }
+ #endregion Sendkey function
+
$Window.Add_Loaded({$Features | Add-FeatureControl})
$Button.Content = $ButtonContent
$Button.Add_Click({& $ButtonAdd_Click})
$Window.Title = $Localization.WindowsFeaturesTitle
+
+ # Force move the WPF form to the foreground
+ $Window.Add_Loaded({$Window.Activate()})
$Form.ShowDialog() | Out-Null
}
@@ -3818,10 +3932,11 @@ function WindowsCapabilities
MinHeight="450" MinWidth="400"
SizeToContent="Width" WindowStartupLocation="CenterScreen"
TextOptions.TextFormattingMode="Display" SnapsToDevicePixels="True"
- FontFamily="Segoe UI" FontSize="12" ShowInTaskbar="False">
+ FontFamily="Candara" FontSize="16" ShowInTaskbar="True">
+
+
+
@@ -3845,7 +3972,7 @@ function WindowsCapabilities
VerticalScrollBarVisibility="Auto">
-
+
'
@@ -4013,11 +4140,55 @@ function WindowsCapabilities
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
+
+ $SetForegroundWindow = @{
+ Namespace = "WinAPI"
+ Name = "ForegroundWindow"
+ Language = "CSharp"
+ MemberDefinition = @"
+[DllImport("user32.dll")]
+public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
+
+[DllImport("user32.dll")]
+[return: MarshalAs(UnmanagedType.Bool)]
+public static extern bool SetForegroundWindow(IntPtr hWnd);
+"@
+ }
+
+ if (-not ("WinAPI.ForegroundWindow" -as [type]))
+ {
+ Add-Type @SetForegroundWindow
+ }
+
+ Get-Process | Where-Object -FilterScript {$_.MainWindowTitle -like "Windows 10 Sophia Script*"} | ForEach-Object -Process {
+ # Show window, if minimized
+ [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10)
+
+ Start-Sleep -Milliseconds 100
+
+ # Force move the console window to the foreground
+ [WinAPI.ForegroundWindow]::SetForegroundWindow($_.MainWindowHandle)
+
+ Start-Sleep -Milliseconds 100
+
+ # Emulate the Backspace key sending
+ [System.Windows.Forms.SendKeys]::SendWait("{BACKSPACE 1}")
+ }
+ #endregion Sendkey function
+
$Window.Add_Loaded({$Capabilities | Add-CapabilityControl})
$Button.Content = $ButtonContent
$Button.Add_Click({& $ButtonAdd_Click})
$Window.Title = $Localization.OptionalFeaturesTitle
+
+ # Force move the WPF form to the foreground
+ $Window.Add_Loaded({$Window.Activate()})
$Form.ShowDialog() | Out-Null
}
@@ -4602,8 +4773,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
MemberDefinition = @"
[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");
@@ -4816,7 +4989,7 @@ public static string GetString(uint strId)
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -4852,7 +5025,7 @@ public static string GetString(uint strId)
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -4888,7 +5061,7 @@ public static string GetString(uint strId)
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -4924,7 +5097,7 @@ public static string GetString(uint strId)
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -4960,7 +5133,7 @@ public static string GetString(uint strId)
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -4996,7 +5169,7 @@ public static string GetString(uint strId)
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -6630,7 +6803,7 @@ function SetAppGraphicsPerformance
$OpenFileDialog.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$OpenFileDialog.Multiselect = $false
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($Focus)
@@ -6830,19 +7003,16 @@ while (`$true)
}
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel" -Name ShowInActionCenter -PropertyType DWord -Value 1 -Force
- # Register the "WindowsCleanup" protocol to be able to run the scheduled task upon clicking on the "Run" button
- if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup))
+ # Register the "WindowsCleanup" protocol to be able to run the scheduled task by clicking the "Run" button in a toast
+ if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup\shell\open\command))
{
- New-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Force
+ New-Item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup\shell\open\command -Force
}
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Name "(default)" -PropertyType String -Value "URL:WindowsCleanup" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Name "URL Protocol" -Value "" -Force
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup -Name EditFlags -PropertyType DWord -Value 2162688 -Force
- if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\shell\open\command))
- {
- New-item -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup\shell\open\command -Force
- }
- # If "Run" clicked run the "Windows Cleanup" task
+
+ # Start the "Windows Cleanup" task if the "Run" button clicked
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\WindowsCleanup\shell\open\command -Name "(default)" -PropertyType String -Value 'powershell.exe -Command "& {Start-ScheduledTask -TaskPath ''\Sophia Script\'' -TaskName ''Windows Cleanup''}"' -Force
$ToastNotification = @"
@@ -7142,7 +7312,7 @@ function AddProtectedFolders
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -7196,7 +7366,7 @@ function AddAppControlledFolder
$OpenFileDialog.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$OpenFileDialog.Multiselect = $false
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($Focus)
@@ -7248,7 +7418,7 @@ function AddDefenderExclusionFolder
$FolderBrowserDialog.Description = $Localization.FolderSelect
$FolderBrowserDialog.RootFolder = "MyComputer"
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$FolderBrowserDialog.ShowDialog($Focus)
@@ -7302,7 +7472,7 @@ function AddDefenderExclusionFile
$OpenFileDialog.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$OpenFileDialog.Multiselect = $false
- # Focus on open file dialog
+ # Force move the open file dialog to the foreground
$Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true}
$OpenFileDialog.ShowDialog($Focus)
@@ -9001,12 +9171,15 @@ 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);
+
+[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("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
+static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
+
public static void Refresh()
{
// Update desktop icons
@@ -9026,6 +9199,7 @@ 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()
{
// Simulate pressing F5 to refresh the desktop