From 8282f042c4daf18387871c5cd583bd7b4af04d22 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Tue, 20 Feb 2024 22:16:11 +0300 Subject: [PATCH] Code improvements --- .../Module/Sophia.psm1 | 230 ++++++++++------- .../Module/Sophia.psm1 | 192 +++++++++----- .../Module/Sophia.psm1 | 196 +++++++++----- .../Module/Sophia.psm1 | 229 ++++++++++------- .../Module/Sophia.psm1 | 240 ++++++++++------- .../Module/Sophia.psm1 | 241 +++++++++++------- 6 files changed, 819 insertions(+), 509 deletions(-) diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index f1a468cf..f054bd70 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -63,9 +63,10 @@ function InitialActions $Script:ProgressPreference = "SilentlyContinue" # 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 $Signature = @{ Namespace = "WinAPI" - Name = "GetStr" + Name = "GetStrings" Language = "CSharp" UsingNamespace = "System.Text" MemberDefinition = @" @@ -82,9 +83,38 @@ public static string GetString(uint strId) LoadString(intPtr, strId, sb, sb.Capacity); return sb.ToString(); } + +// Get string from other DLLs +[DllImport("shlwapi.dll", CharSet=CharSet.Unicode)] +private static extern int SHLoadIndirectString(string pszSource, StringBuilder pszOutBuf, int cchOutBuf, string ppvReserved); + +public static string GetIndirectString(string indirectString) +{ + try + { + int returnValue; + StringBuilder lptStr = new StringBuilder(1024); + returnValue = SHLoadIndirectString(indirectString, lptStr, 1024, null); + + if (returnValue == 0) + { + return lptStr.ToString(); + } + else + { + return null; + // return "SHLoadIndirectString Failure: " + returnValue; + } + } + catch // (Exception ex) + { + return null; + // return "Exception Message: " + ex.Message; + } +} "@ } - if (-not ("WinAPI.GetStr" -as [type])) + if (-not ("WinAPI.GetStrings" -as [type])) { try { @@ -109,7 +139,7 @@ public static string GetString(uint strId) { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose try { @@ -160,16 +190,7 @@ public static string GetString(uint strId) { & "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized } - catch [System.InvalidOperationException] - { - Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge") - - Start-Process -FilePath "https://t.me/sophia_chat" - Start-Process -FilePath "https://discord.gg/sSryhaEv79" - - exit - } - catch [System.Management.Automation.ApplicationFailedException] + catch { Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge") @@ -360,7 +381,7 @@ public static string GetString(uint strId) if ((Get-Service -Name EventLog).Status -eq "Stopped") { # Extract the localized "Event Viewer" string from shell32.dll - Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStr]::GetString(22029))) + Write-Warning -Message ($Localization.WindowsComponentBroken -f $([WinAPI.GetStrings]::GetString(22029))) Start-Process -FilePath "https://t.me/sophia_chat" Start-Process -FilePath "https://discord.gg/sSryhaEv79" @@ -443,6 +464,7 @@ public static string GetString(uint strId) try { $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop + Get-Service -Name SecurityHealthService -ErrorAction Stop | Start-Service } catch [Microsoft.PowerShell.Commands.ServiceCommandException] { @@ -700,7 +722,7 @@ public static string GetString(uint strId) Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose Write-Information -MessageData "" -InformationAction Continue # Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker @@ -790,7 +812,7 @@ public static string GetString(uint strId) Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose Write-Information -MessageData "" -InformationAction Continue # Check whether hosts contains any of string from $IPArray array @@ -830,6 +852,34 @@ public static string GetString(uint strId) Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue } + # Register a temp schedule task to check whether there's a Windows bug presented + $Action = New-ScheduledTaskAction -Execute powershell.exe + $Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable + $Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest + $Parameters = @{ + TaskName = "SophiaTempScheduledTask" + Principal = $Principal + Action = $Action + Settings = $Settings + } + try + { + Register-ScheduledTask @Parameters -Force -ErrorAction Stop + } + catch [Microsoft.Management.Infrastructure.CimException] + { + Write-Verbose -Message ($Localization.WindowsComponentBroken -f [WinAPI.GetStrings]::GetIndirectString("@%SystemRoot%\system32\schedsvc.dll,-100")) -Verbose + + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + exit + } + + # Remove temp schedule task + Unregister-ScheduledTask -TaskName SophiaTempScheduledTask -Confirm:$false -ErrorAction Ignore + # PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore @@ -881,7 +931,7 @@ public static string GetString(uint strId) if ($AddSkip) { # Extract the localized "Skip" string from shell32.dll - $Menu += [WinAPI.GetStr]::GetString(16956) + $Menu += [WinAPI.GetStrings]::GetString(16956) } # https://github.com/microsoft/terminal/issues/14992 @@ -936,14 +986,14 @@ public static string GetString(uint strId) } # Extract the localized "Browse" string from shell32.dll - $Script:Browse = [WinAPI.GetStr]::GetString(9015) + $Script:Browse = [WinAPI.GetStrings]::GetString(9015) # Extract the localized "&No" string from shell32.dll - $Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "") + $Script:No = [WinAPI.GetStrings]::GetString(33232).Replace("&", "") # Extract the localized "&Yes" string from shell32.dll - $Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "") + $Script:Yes = [WinAPI.GetStrings]::GetString(33224).Replace("&", "") $Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193) # Extract the localized "Skip" string from shell32.dll - $Script:Skip = [WinAPI.GetStr]::GetString(16956) + $Script:Skip = [WinAPI.GetStrings]::GetString(16956) # Display a warning message about whether a user has customized the preset file if ($Warning) @@ -1165,7 +1215,7 @@ function DiagTrackService ) # Check whether "InitialActions" function was removed in preset file - if (-not ("WinAPI.GetStr" -as [type])) + if (-not ("WinAPI.GetStrings" -as [type])) { # Get the name of a preset (e.g Sophia.ps1) regardless it was named # $_.File has no EndsWith() method @@ -1582,7 +1632,7 @@ function ScheduledTasks { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose [void]$Window.Close() @@ -1594,7 +1644,7 @@ function ScheduledTasks { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose [void]$Window.Close() @@ -1647,7 +1697,7 @@ function ScheduledTasks { $State = "Disabled" # Extract the localized "Enable" string from shell32.dll - $ButtonContent = [WinAPI.GetStr]::GetString(51472) + $ButtonContent = [WinAPI.GetStrings]::GetString(51472) $ButtonAdd_Click = {EnableButton} } "Disable" @@ -1660,7 +1710,7 @@ function ScheduledTasks Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Getting list of all scheduled tasks according to the conditions $Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)} @@ -4040,7 +4090,7 @@ function UnpinTaskbarShortcuts ) # Extract the localized "Unpin from taskbar" string from shell32.dll - $LocalizedString = [WinAPI.GetStr]::GetString(5387) + $LocalizedString = [WinAPI.GetStrings]::GetString(5387) foreach ($Shortcut in $Shortcuts) { @@ -4054,7 +4104,7 @@ function UnpinTaskbarShortcuts $Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar") $Shortcut = $Shell.ParseName("Microsoft Edge.lnk") # Extract the localized "Unpin from taskbar" string from shell32.dll - $Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq "$([WinAPI.GetStr]::GetString(5387))"} | ForEach-Object -Process {$_.DoIt()} + $Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq "$([WinAPI.GetStrings]::GetString(5387))"} | ForEach-Object -Process {$_.DoIt()} } } Store @@ -6469,7 +6519,7 @@ function WindowsFeatures { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose [void]$Window.Close() @@ -6481,7 +6531,7 @@ function WindowsFeatures { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose [void]$Window.Close() @@ -6551,7 +6601,7 @@ function WindowsFeatures Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Getting list of all optional features according to the conditions $OFS = "|" @@ -6827,7 +6877,7 @@ function WindowsCapabilities { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose [void]$Window.Close() @@ -6845,7 +6895,7 @@ function WindowsCapabilities { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose [void]$Window.Close() @@ -6944,7 +6994,7 @@ function WindowsCapabilities Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Getting list of all capabilities according to the conditions $OFS = "|" @@ -7167,7 +7217,7 @@ function NetworkAdaptersSavePower Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress}) { @@ -7207,7 +7257,7 @@ function NetworkAdaptersSavePower { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose Start-Sleep -Seconds 2 } @@ -7270,7 +7320,7 @@ function IPv6Component Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose try { @@ -7637,10 +7687,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Desktop Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Verbose + Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21769)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7665,10 +7715,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Documents Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Verbose + Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21770)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7693,10 +7743,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Downloads Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21798)) -Verbose + Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21798)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7721,10 +7771,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Music Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Verbose + Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21790)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7749,10 +7799,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Pictures Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Verbose + Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21779)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7777,10 +7827,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Videos Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Verbose + Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21791)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7807,10 +7857,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { # Desktop Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769)) -Verbose + Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStrings]::GetString(21769)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7847,10 +7897,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Documents Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770)) -Verbose + Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStrings]::GetString(21770)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7887,10 +7937,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Downloads Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21798)) -Verbose + Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStrings]::GetString(21798)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7927,10 +7977,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Music Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790)) -Verbose + Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStrings]::GetString(21790)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -7967,10 +8017,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Pictures Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779)) -Verbose + Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStrings]::GetString(21779)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -8007,10 +8057,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Videos Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791)) -Verbose + Write-Verbose -Message ($Localization.UserFolderRequest -f [WinAPI.GetStrings]::GetString(21791)) -Verbose $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -8049,11 +8099,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { # Desktop Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769)) -Verbose + Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStrings]::GetString(21769)) -Verbose # Extract the localized "Desktop" string from shell32.dll $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -8078,11 +8128,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Documents Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770)) -Verbose + Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStrings]::GetString(21770)) -Verbose # Extract the localized "Documents" string from shell32.dll $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -8107,11 +8157,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Downloads Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798)) -Verbose + Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStrings]::GetString(21798)) -Verbose # Extract the localized "Downloads" string from shell32.dll $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -8136,11 +8186,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Music Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790)) -Verbose + Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStrings]::GetString(21790)) -Verbose # Extract the localized "Music" string from shell32.dll $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -8165,11 +8215,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Pictures Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779)) -Verbose + Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStrings]::GetString(21779)) -Verbose # Extract the localized "Pictures" string from shell32.dll $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -8194,11 +8244,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int # Videos Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791)) -Verbose + Write-Verbose -Message ($Localization.UserDefaultFolder -f [WinAPI.GetStrings]::GetString(21791)) -Verbose # Extract the localized "Pictures" string from shell32.dll $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" - Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose + Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStrings]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved do @@ -9975,7 +10025,7 @@ public static long MakeLong(uint left, uint right) Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose # Register %1 argument if ProgId exists as an executable file if (Test-Path -Path $ProgramPath) @@ -11424,7 +11474,7 @@ function PinToStart process { # Extract the localized "Devices and Printers" string from shell32.dll - $DevicesPrinters = [WinAPI.GetStr]::GetString(30493) + $DevicesPrinters = [WinAPI.GetStrings]::GetString(30493) # Check whether an argument is "DevicesPrinters". The Devices and Printers's AppID attribute can be retrieved only if the shortcut was created if (((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Where-Object -FilterScript {$_ -match "DevicesPrinters"}) @@ -11510,7 +11560,7 @@ function PinToStart { ControlPanel { - $ControlPanel = [WinAPI.GetStr]::GetString(12712) + $ControlPanel = [WinAPI.GetStrings]::GetString(12712) Write-Verbose -Message ($Localization.ShortcutPinning -f $ControlPanel) -Verbose } DevicesPrinters @@ -11812,7 +11862,7 @@ function UninstallUWPApps $ButtonUninstall.Content = $Localization.Uninstall $TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll # Extract the localized "Select all" string from shell32.dll - $TextBlockSelectAll.Text = [WinAPI.GetStr]::GetString(31276) + $TextBlockSelectAll.Text = [WinAPI.GetStrings]::GetString(31276) $ButtonUninstall.Add_Click({ButtonUninstallClick}) $CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick}) @@ -11834,7 +11884,7 @@ function UninstallUWPApps Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages}) @@ -11945,7 +11995,7 @@ function UninstallUWPApps { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose $Window.Close() | Out-Null @@ -12186,7 +12236,7 @@ function RestoreUWPApps $Window.Title = $Localization.UWPAppsTitle $ButtonRestore.Content = $Localization.Restore # Extract the localized "Select all" string from shell32.dll - $TextBlockSelectAll.Text = [WinAPI.GetStr]::GetString(31276) + $TextBlockSelectAll.Text = [WinAPI.GetStrings]::GetString(31276) $ButtonRestore.Add_Click({ButtonRestoreClick}) $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick}) @@ -12197,7 +12247,7 @@ function RestoreUWPApps { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + 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 @@ -12279,7 +12329,7 @@ function RestoreUWPApps { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose $Window.Close() | Out-Null @@ -12538,7 +12588,7 @@ function HEVC { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll - Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose + Write-Verbose -Message ([WinAPI.GetStrings]::GetString(12612)) -Verbose Write-Verbose -Message $Localization.HEVCDownloading -Verbose @@ -13303,7 +13353,7 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")