Browse Source

Code improvements

master
Dmitry Nefedov 10 months ago
parent
commit
8282f042c4
  1. 230
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 192
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 196
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 229
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 240
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 241
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

230
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -63,9 +63,10 @@ function InitialActions
$Script:ProgressPreference = "SilentlyContinue" $Script:ProgressPreference = "SilentlyContinue"
# Extract strings from %SystemRoot%\System32\shell32.dll using its' number # 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 = @{ $Signature = @{
Namespace = "WinAPI" Namespace = "WinAPI"
Name = "GetStr" Name = "GetStrings"
Language = "CSharp" Language = "CSharp"
UsingNamespace = "System.Text" UsingNamespace = "System.Text"
MemberDefinition = @" MemberDefinition = @"
@ -82,9 +83,38 @@ public static string GetString(uint strId)
LoadString(intPtr, strId, sb, sb.Capacity); LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString(); 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 try
{ {
@ -109,7 +139,7 @@ public static string GetString(uint strId)
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 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 & "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
} }
catch [System.InvalidOperationException] catch
{
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]
{ {
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge") 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") if ((Get-Service -Name EventLog).Status -eq "Stopped")
{ {
# Extract the localized "Event Viewer" string from shell32.dll # 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://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79" Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -443,6 +464,7 @@ public static string GetString(uint strId)
try try
{ {
$Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
Get-Service -Name SecurityHealthService -ErrorAction Stop | Start-Service
} }
catch [Microsoft.PowerShell.Commands.ServiceCommandException] catch [Microsoft.PowerShell.Commands.ServiceCommandException]
{ {
@ -700,7 +722,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker # 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 Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Check whether hosts contains any of string from $IPArray array # 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 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 # 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 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) if ($AddSkip)
{ {
# Extract the localized "Skip" string from shell32.dll # 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 # 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 # 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 # 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 # 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) $Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
# Extract the localized "Skip" string from shell32.dll # 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 # Display a warning message about whether a user has customized the preset file
if ($Warning) if ($Warning)
@ -1165,7 +1215,7 @@ function DiagTrackService
) )
# Check whether "InitialActions" function was removed in preset file # 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 # Get the name of a preset (e.g Sophia.ps1) regardless it was named
# $_.File has no EndsWith() method # $_.File has no EndsWith() method
@ -1582,7 +1632,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1594,7 +1644,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1647,7 +1697,7 @@ function ScheduledTasks
{ {
$State = "Disabled" $State = "Disabled"
# Extract the localized "Enable" string from shell32.dll # Extract the localized "Enable" string from shell32.dll
$ButtonContent = [WinAPI.GetStr]::GetString(51472) $ButtonContent = [WinAPI.GetStrings]::GetString(51472)
$ButtonAdd_Click = {EnableButton} $ButtonAdd_Click = {EnableButton}
} }
"Disable" "Disable"
@ -1660,7 +1710,7 @@ function ScheduledTasks
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all scheduled tasks according to the conditions
$Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)} $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 # Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387) $LocalizedString = [WinAPI.GetStrings]::GetString(5387)
foreach ($Shortcut in $Shortcuts) 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") $Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk") $Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll # 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 Store
@ -6469,7 +6519,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6481,7 +6531,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6551,7 +6601,7 @@ function WindowsFeatures
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all optional features according to the conditions
$OFS = "|" $OFS = "|"
@ -6827,7 +6877,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6845,7 +6895,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6944,7 +6994,7 @@ function WindowsCapabilities
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all capabilities according to the conditions
$OFS = "|" $OFS = "|"
@ -7167,7 +7217,7 @@ function NetworkAdaptersSavePower
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{ {
@ -7207,7 +7257,7 @@ function NetworkAdaptersSavePower
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Start-Sleep -Seconds 2
} }
@ -7270,7 +7320,7 @@ function IPv6Component
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -7637,10 +7687,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7665,10 +7715,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7693,10 +7743,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7721,10 +7771,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7749,10 +7799,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7777,10 +7827,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7807,10 +7857,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7847,10 +7897,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7887,10 +7937,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7927,10 +7977,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7967,10 +8017,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8007,10 +8057,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8049,11 +8099,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Desktop" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8078,11 +8128,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Documents" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8107,11 +8157,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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 # 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8136,11 +8186,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Music" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8165,11 +8215,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8194,11 +8244,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -9975,7 +10025,7 @@ public static long MakeLong(uint left, uint right)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Register %1 argument if ProgId exists as an executable file
if (Test-Path -Path $ProgramPath) if (Test-Path -Path $ProgramPath)
@ -11424,7 +11474,7 @@ function PinToStart
process process
{ {
# Extract the localized "Devices and Printers" string from shell32.dll # 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 # 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"}) 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
{ {
$ControlPanel = [WinAPI.GetStr]::GetString(12712) $ControlPanel = [WinAPI.GetStrings]::GetString(12712)
Write-Verbose -Message ($Localization.ShortcutPinning -f $ControlPanel) -Verbose Write-Verbose -Message ($Localization.ShortcutPinning -f $ControlPanel) -Verbose
} }
DevicesPrinters DevicesPrinters
@ -11812,7 +11862,7 @@ function UninstallUWPApps
$ButtonUninstall.Content = $Localization.Uninstall $ButtonUninstall.Content = $Localization.Uninstall
$TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll $TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonUninstall.Add_Click({ButtonUninstallClick})
$CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick}) $CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick})
@ -11834,7 +11884,7 @@ function UninstallUWPApps
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
@ -11945,7 +11995,7 @@ function UninstallUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -12186,7 +12236,7 @@ function RestoreUWPApps
$Window.Title = $Localization.UWPAppsTitle $Window.Title = $Localization.UWPAppsTitle
$ButtonRestore.Content = $Localization.Restore $ButtonRestore.Content = $Localization.Restore
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonRestore.Add_Click({ButtonRestoreClick})
$CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick}) $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
@ -12197,7 +12247,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # 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 $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
@ -12279,7 +12329,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -12538,7 +12588,7 @@ function HEVC
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Verbose -Message $Localization.HEVCDownloading -Verbose
@ -13303,7 +13353,7 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action content="$([WinAPI.GetStr]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/> <action content="$([WinAPI.GetStrings]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/>
<action content="" arguments="dismiss" activationType="system"/> <action content="" arguments="dismiss" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15821,7 +15871,7 @@ function UpdateLGPEPolicies
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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.GPOUpdate -Verbose Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Verbose -Message HKLM -Verbose Write-Verbose -Message HKLM -Verbose
@ -16118,7 +16168,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -16146,7 +16196,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophianews" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophianews" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -16174,7 +16224,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -16190,7 +16240,7 @@ public static void PostMessage()
# Check for UWP apps updates # Check for UWP apps updates
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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
Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod
} }
@ -16211,7 +16261,7 @@ function Errors
[PSCustomObject]@{ [PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber $Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll # Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStr]::GetString(4130))" = $ErrorInFile "$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message $Localization.ErrorsMessage = $_.Exception.Message
} }
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim() } | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()

192
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -63,9 +63,10 @@ function InitialActions
$Script:ProgressPreference = "SilentlyContinue" $Script:ProgressPreference = "SilentlyContinue"
# Extract strings from %SystemRoot%\System32\shell32.dll using its' number # 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 = @{ $Signature = @{
Namespace = "WinAPI" Namespace = "WinAPI"
Name = "GetStr" Name = "GetStrings"
Language = "CSharp" Language = "CSharp"
UsingNamespace = "System.Text" UsingNamespace = "System.Text"
MemberDefinition = @" MemberDefinition = @"
@ -82,9 +83,38 @@ public static string GetString(uint strId)
LoadString(intPtr, strId, sb, sb.Capacity); LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString(); 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 try
{ {
@ -257,7 +287,7 @@ public static string GetString(uint strId)
if ((Get-Service -Name EventLog).Status -eq "Stopped") if ((Get-Service -Name EventLog).Status -eq "Stopped")
{ {
# Extract the localized "Event Viewer" string from shell32.dll # 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://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79" Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -329,6 +359,7 @@ public static string GetString(uint strId)
try try
{ {
$Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
Get-Service -Name SecurityHealthService -ErrorAction Stop | Start-Service
} }
catch [Microsoft.PowerShell.Commands.ServiceCommandException] catch [Microsoft.PowerShell.Commands.ServiceCommandException]
{ {
@ -579,7 +610,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker # Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker
@ -669,7 +700,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Check whether hosts contains any of string from $IPArray array # Check whether hosts contains any of string from $IPArray array
@ -709,6 +740,33 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue 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 = "SophiaTest"
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
}
Unregister-ScheduledTask -TaskName SophiaTest -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 # 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 Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
@ -760,7 +818,7 @@ public static string GetString(uint strId)
if ($AddSkip) if ($AddSkip)
{ {
# Extract the localized "Skip" string from shell32.dll # 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 # https://github.com/microsoft/terminal/issues/14992
@ -815,14 +873,14 @@ public static string GetString(uint strId)
} }
# Extract the localized "Browse" string from shell32.dll # 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 # 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 # 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) $Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
# Extract the localized "Skip" string from shell32.dll # 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 # Display a warning message about whether a user has customized the preset file
if ($Warning) if ($Warning)
@ -1041,7 +1099,7 @@ function DiagTrackService
) )
# Check whether "InitialActions" function was removed in preset file # 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 # Get the name of a preset (e.g Sophia.ps1) regardless it was named
# $_.File has no EndsWith() method # $_.File has no EndsWith() method
@ -1448,7 +1506,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1460,7 +1518,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1513,7 +1571,7 @@ function ScheduledTasks
{ {
$State = "Disabled" $State = "Disabled"
# Extract the localized "Enable" string from shell32.dll # Extract the localized "Enable" string from shell32.dll
$ButtonContent = [WinAPI.GetStr]::GetString(51472) $ButtonContent = [WinAPI.GetStrings]::GetString(51472)
$ButtonAdd_Click = {EnableButton} $ButtonAdd_Click = {EnableButton}
} }
"Disable" "Disable"
@ -1526,7 +1584,7 @@ function ScheduledTasks
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all scheduled tasks according to the conditions
$Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)} $Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)}
@ -5099,7 +5157,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5111,7 +5169,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5181,7 +5239,7 @@ function WindowsFeatures
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all optional features according to the conditions
$OFS = "|" $OFS = "|"
@ -5442,7 +5500,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5460,7 +5518,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5559,7 +5617,7 @@ function WindowsCapabilities
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all capabilities according to the conditions
$OFS = "|" $OFS = "|"
@ -5782,7 +5840,7 @@ function NetworkAdaptersSavePower
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{ {
@ -5822,7 +5880,7 @@ function NetworkAdaptersSavePower
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Start-Sleep -Seconds 2
} }
@ -5885,7 +5943,7 @@ function IPv6Component
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -6252,10 +6310,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6280,10 +6338,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6308,10 +6366,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6336,10 +6394,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6364,10 +6422,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6392,10 +6450,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6422,10 +6480,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6462,10 +6520,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6502,10 +6560,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6542,10 +6600,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6582,10 +6640,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6622,10 +6680,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6664,11 +6722,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Desktop" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6693,11 +6751,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Documents" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6722,11 +6780,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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 # 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6751,11 +6809,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Music" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6780,11 +6838,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6809,11 +6867,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8242,7 +8300,7 @@ public static long MakeLong(uint left, uint right)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Register %1 argument if ProgId exists as an executable file
if (Test-Path -Path $ProgramPath) if (Test-Path -Path $ProgramPath)
@ -9761,7 +9819,7 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action content="$([WinAPI.GetStr]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/> <action content="$([WinAPI.GetStrings]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/>
<action content="" arguments="dismiss" activationType="system"/> <action content="" arguments="dismiss" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -12056,7 +12114,7 @@ function UpdateLGPEPolicies
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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.GPOUpdate -Verbose Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Verbose -Message HKLM -Verbose Write-Verbose -Message HKLM -Verbose
@ -12343,7 +12401,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -12371,7 +12429,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophianews" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophianews" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -12399,7 +12457,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -12429,7 +12487,7 @@ function Errors
[PSCustomObject]@{ [PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber $Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll # Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStr]::GetString(4130))" = $ErrorInFile "$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message $Localization.ErrorsMessage = $_.Exception.Message
} }
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim() } | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()

196
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -63,9 +63,10 @@ function InitialActions
$Script:ProgressPreference = "SilentlyContinue" $Script:ProgressPreference = "SilentlyContinue"
# Extract strings from %SystemRoot%\System32\shell32.dll using its' number # 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 = @{ $Signature = @{
Namespace = "WinAPI" Namespace = "WinAPI"
Name = "GetStr" Name = "GetStrings"
Language = "CSharp" Language = "CSharp"
UsingNamespace = "System.Text" UsingNamespace = "System.Text"
MemberDefinition = @" MemberDefinition = @"
@ -82,9 +83,38 @@ public static string GetString(uint strId)
LoadString(intPtr, strId, sb, sb.Capacity); LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString(); 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 try
{ {
@ -257,7 +287,7 @@ public static string GetString(uint strId)
if ((Get-Service -Name EventLog).Status -eq "Stopped") if ((Get-Service -Name EventLog).Status -eq "Stopped")
{ {
# Extract the localized "Event Viewer" string from shell32.dll # 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://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79" Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -329,6 +359,7 @@ public static string GetString(uint strId)
try try
{ {
$Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
Get-Service -Name SecurityHealthService -ErrorAction Stop | Start-Service
} }
catch [Microsoft.PowerShell.Commands.ServiceCommandException] catch [Microsoft.PowerShell.Commands.ServiceCommandException]
{ {
@ -579,7 +610,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker # Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker
@ -669,7 +700,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Check whether hosts contains any of string from $IPArray array # Check whether hosts contains any of string from $IPArray array
@ -709,6 +740,33 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue 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 = "SophiaTest"
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
}
Unregister-ScheduledTask -TaskName SophiaTest -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 # 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 Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
@ -760,7 +818,7 @@ public static string GetString(uint strId)
if ($AddSkip) if ($AddSkip)
{ {
# Extract the localized "Skip" string from shell32.dll # 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 # https://github.com/microsoft/terminal/issues/14992
@ -815,14 +873,14 @@ public static string GetString(uint strId)
} }
# Extract the localized "Browse" string from shell32.dll # 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 # 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 # 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) $Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
# Extract the localized "Skip" string from shell32.dll # 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 # Display a warning message about whether a user has customized the preset file
if ($Warning) if ($Warning)
@ -1041,7 +1099,7 @@ function DiagTrackService
) )
# Check whether "InitialActions" function was removed in preset file # 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 # Get the name of a preset (e.g Sophia.ps1) regardless it was named
# $_.File has no EndsWith() method # $_.File has no EndsWith() method
@ -1448,7 +1506,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1460,7 +1518,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1513,7 +1571,7 @@ function ScheduledTasks
{ {
$State = "Disabled" $State = "Disabled"
# Extract the localized "Enable" string from shell32.dll # Extract the localized "Enable" string from shell32.dll
$ButtonContent = [WinAPI.GetStr]::GetString(51472) $ButtonContent = [WinAPI.GetStrings]::GetString(51472)
$ButtonAdd_Click = {EnableButton} $ButtonAdd_Click = {EnableButton}
} }
"Disable" "Disable"
@ -1526,7 +1584,7 @@ function ScheduledTasks
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all scheduled tasks according to the conditions
$Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)} $Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)}
@ -5472,7 +5530,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5484,7 +5542,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5554,7 +5612,7 @@ function WindowsFeatures
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all optional features according to the conditions
$OFS = "|" $OFS = "|"
@ -5830,7 +5888,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5848,7 +5906,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5947,7 +6005,7 @@ function WindowsCapabilities
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all capabilities according to the conditions
$OFS = "|" $OFS = "|"
@ -6170,7 +6228,7 @@ function NetworkAdaptersSavePower
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{ {
@ -6210,7 +6268,7 @@ function NetworkAdaptersSavePower
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Start-Sleep -Seconds 2
} }
@ -6273,7 +6331,7 @@ function IPv6Component
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -6640,10 +6698,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6668,10 +6726,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6696,10 +6754,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6724,10 +6782,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6752,10 +6810,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6780,10 +6838,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6810,10 +6868,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6850,10 +6908,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6890,10 +6948,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6930,10 +6988,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -6970,10 +7028,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7010,10 +7068,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7052,11 +7110,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Desktop" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7081,11 +7139,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Documents" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7110,11 +7168,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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 # 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7139,11 +7197,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Music" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7168,11 +7226,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7197,11 +7255,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8869,7 +8927,7 @@ public static long MakeLong(uint left, uint right)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Register %1 argument if ProgId exists as an executable file
if (Test-Path -Path $ProgramPath) if (Test-Path -Path $ProgramPath)
@ -10270,7 +10328,7 @@ function PinToStart
process process
{ {
# Extract the localized "Devices and Printers" string from shell32.dll # 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 # 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"}) if (((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Where-Object -FilterScript {$_ -match "DevicesPrinters"})
@ -10356,7 +10414,7 @@ function PinToStart
{ {
ControlPanel ControlPanel
{ {
$ControlPanel = [WinAPI.GetStr]::GetString(12712) $ControlPanel = [WinAPI.GetStrings]::GetString(12712)
Write-Verbose -Message ($Localization.ShortcutPinning -f $ControlPanel) -Verbose Write-Verbose -Message ($Localization.ShortcutPinning -f $ControlPanel) -Verbose
} }
DevicesPrinters DevicesPrinters
@ -10914,7 +10972,7 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action content="$([WinAPI.GetStr]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/> <action content="$([WinAPI.GetStrings]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/>
<action content="" arguments="dismiss" activationType="system"/> <action content="" arguments="dismiss" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -13263,7 +13321,7 @@ function UpdateLGPEPolicies
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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.GPOUpdate -Verbose Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Verbose -Message HKLM -Verbose Write-Verbose -Message HKLM -Verbose
@ -13550,7 +13608,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -13578,7 +13636,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophianews" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophianews" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -13606,7 +13664,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -13636,7 +13694,7 @@ function Errors
[PSCustomObject]@{ [PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber $Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll # Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStr]::GetString(4130))" = $ErrorInFile "$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message $Localization.ErrorsMessage = $_.Exception.Message
} }
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim() } | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()

229
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -59,9 +59,10 @@ function InitialActions
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Extract strings from %SystemRoot%\System32\shell32.dll using its' number # 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 = @{ $Signature = @{
Namespace = "WinAPI" Namespace = "WinAPI"
Name = "GetStr" Name = "GetStrings"
Language = "CSharp" Language = "CSharp"
UsingNamespace = "System.Text" UsingNamespace = "System.Text"
MemberDefinition = @" MemberDefinition = @"
@ -78,9 +79,38 @@ public static string GetString(uint strId)
LoadString(intPtr, strId, sb, sb.Capacity); LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString(); 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]))
{ {
Add-Type @Signature Add-Type @Signature
} }
@ -90,7 +120,7 @@ public static string GetString(uint strId)
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -141,16 +171,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 & "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
} }
catch [System.InvalidOperationException] catch
{
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]
{ {
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge") Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge")
@ -341,7 +362,7 @@ public static string GetString(uint strId)
if ((Get-Service -Name EventLog).Status -eq "Stopped") if ((Get-Service -Name EventLog).Status -eq "Stopped")
{ {
# Extract the localized "Event Viewer" string from shell32.dll # 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://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79" Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -424,6 +445,7 @@ public static string GetString(uint strId)
try try
{ {
$Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
Get-Service -Name SecurityHealthService -ErrorAction Stop | Start-Service
} }
catch [Microsoft.PowerShell.Commands.ServiceCommandException] catch [Microsoft.PowerShell.Commands.ServiceCommandException]
{ {
@ -686,7 +708,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker # Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker
@ -776,7 +798,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Check whether hosts contains any of string from $IPArray array # Check whether hosts contains any of string from $IPArray array
@ -816,6 +838,33 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue 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 = "SophiaTest"
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
}
Unregister-ScheduledTask -TaskName SophiaTest -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 # 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 Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
@ -870,7 +919,7 @@ public static string GetString(uint strId)
if ($AddSkip) if ($AddSkip)
{ {
# Extract the localized "Skip" string from shell32.dll # 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 # https://github.com/microsoft/terminal/issues/14992
@ -925,14 +974,14 @@ public static string GetString(uint strId)
} }
# Extract the localized "Browse" string from shell32.dll # 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 # 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 # 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) $Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
# Extract the localized "Skip" string from shell32.dll # 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 # Display a warning message about whether a user has customized the preset file
if ($Warning) if ($Warning)
@ -1154,7 +1203,7 @@ function DiagTrackService
) )
# Check whether "InitialActions" function was removed in preset file # 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 # Get the name of a preset (e.g Sophia.ps1) regardless it was named
# $_.File has no EndsWith() method # $_.File has no EndsWith() method
@ -1571,7 +1620,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1583,7 +1632,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1636,7 +1685,7 @@ function ScheduledTasks
{ {
$State = "Disabled" $State = "Disabled"
# Extract the localized "Enable" string from shell32.dll # Extract the localized "Enable" string from shell32.dll
$ButtonContent = [WinAPI.GetStr]::GetString(51472) $ButtonContent = [WinAPI.GetStrings]::GetString(51472)
$ButtonAdd_Click = {EnableButton} $ButtonAdd_Click = {EnableButton}
} }
"Disable" "Disable"
@ -1649,7 +1698,7 @@ function ScheduledTasks
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all scheduled tasks according to the conditions
$Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)} $Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)}
@ -4029,7 +4078,7 @@ function UnpinTaskbarShortcuts
) )
# Extract the localized "Unpin from taskbar" string from shell32.dll # Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387) $LocalizedString = [WinAPI.GetStrings]::GetString(5387)
foreach ($Shortcut in $Shortcuts) foreach ($Shortcut in $Shortcuts)
{ {
@ -4043,7 +4092,7 @@ function UnpinTaskbarShortcuts
$Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar") $Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk") $Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll # 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 Store
@ -6458,7 +6507,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6470,7 +6519,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6540,7 +6589,7 @@ function WindowsFeatures
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all optional features according to the conditions
$OFS = "|" $OFS = "|"
@ -6816,7 +6865,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6834,7 +6883,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6933,7 +6982,7 @@ function WindowsCapabilities
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all capabilities according to the conditions
$OFS = "|" $OFS = "|"
@ -7156,7 +7205,7 @@ function NetworkAdaptersSavePower
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{ {
@ -7196,7 +7245,7 @@ function NetworkAdaptersSavePower
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Start-Sleep -Seconds 2
} }
@ -7259,7 +7308,7 @@ function IPv6Component
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -7626,10 +7675,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7654,10 +7703,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7682,10 +7731,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7710,10 +7759,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7738,10 +7787,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7766,10 +7815,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7796,10 +7845,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7836,10 +7885,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7876,10 +7925,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7916,10 +7965,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7956,10 +8005,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7996,10 +8045,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8038,11 +8087,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Desktop" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8067,11 +8116,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Documents" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8096,11 +8145,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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 # 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8125,11 +8174,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Music" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8154,11 +8203,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -8183,11 +8232,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -9964,7 +10013,7 @@ public static long MakeLong(uint left, uint right)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Register %1 argument if ProgId exists as an executable file
if (Test-Path -Path $ProgramPath) if (Test-Path -Path $ProgramPath)
@ -11413,7 +11462,7 @@ function PinToStart
process process
{ {
# Extract the localized "Devices and Printers" string from shell32.dll # 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 # 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"}) if (((Get-Command -Name PinToStart).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Where-Object -FilterScript {$_ -match "DevicesPrinters"})
@ -11499,7 +11548,7 @@ function PinToStart
{ {
ControlPanel ControlPanel
{ {
$ControlPanel = [WinAPI.GetStr]::GetString(12712) $ControlPanel = [WinAPI.GetStrings]::GetString(12712)
Write-Verbose -Message ($Localization.ShortcutPinning -f $ControlPanel) -Verbose Write-Verbose -Message ($Localization.ShortcutPinning -f $ControlPanel) -Verbose
} }
DevicesPrinters DevicesPrinters
@ -11811,7 +11860,7 @@ function UninstallUWPApps
$ButtonUninstall.Content = $Localization.Uninstall $ButtonUninstall.Content = $Localization.Uninstall
$TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll $TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonUninstall.Add_Click({ButtonUninstallClick})
$CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick}) $CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick})
@ -11833,7 +11882,7 @@ function UninstallUWPApps
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
@ -11944,7 +11993,7 @@ function UninstallUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -12195,7 +12244,7 @@ function RestoreUWPApps
$Window.Title = $Localization.UWPAppsTitle $Window.Title = $Localization.UWPAppsTitle
$ButtonRestore.Content = $Localization.Restore $ButtonRestore.Content = $Localization.Restore
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonRestore.Add_Click({ButtonRestoreClick})
$CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick}) $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
@ -12206,7 +12255,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # 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 $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
@ -12288,7 +12337,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -12547,7 +12596,7 @@ function HEVC
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Verbose -Message $Localization.HEVCDownloading -Verbose
@ -13312,7 +13361,7 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action content="$([WinAPI.GetStr]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/> <action content="$([WinAPI.GetStrings]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/>
<action content="" arguments="dismiss" activationType="system"/> <action content="" arguments="dismiss" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15830,7 +15879,7 @@ function UpdateLGPEPolicies
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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.GPOUpdate -Verbose Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Verbose -Message HKLM -Verbose Write-Verbose -Message HKLM -Verbose
@ -16127,7 +16176,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -16155,7 +16204,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophianews" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophianews" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -16183,7 +16232,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -16199,7 +16248,7 @@ public static void PostMessage()
# Check for UWP apps updates # Check for UWP apps updates
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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
Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod
} }
@ -16220,7 +16269,7 @@ function Errors
[PSCustomObject]@{ [PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber $Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll # Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStr]::GetString(4130))" = $ErrorInFile "$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message $Localization.ErrorsMessage = $_.Exception.Message
} }
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim() } | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()

240
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -62,9 +62,10 @@ function InitialActions
$Script:ProgressPreference = "SilentlyContinue" $Script:ProgressPreference = "SilentlyContinue"
# Extract strings from %SystemRoot%\System32\shell32.dll using its' number # 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 = @{ $Signature = @{
Namespace = "WinAPI" Namespace = "WinAPI"
Name = "GetStr" Name = "GetStrings"
Language = "CSharp" Language = "CSharp"
UsingNamespace = "System.Text" UsingNamespace = "System.Text"
MemberDefinition = @" MemberDefinition = @"
@ -81,9 +82,38 @@ public static string GetString(uint strId)
LoadString(intPtr, strId, sb, sb.Capacity); LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString(); 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 try
{ {
@ -108,7 +138,7 @@ public static string GetString(uint strId)
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -159,16 +189,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 & "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
} }
catch [System.InvalidOperationException] catch
{
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]
{ {
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge") Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge")
@ -348,7 +369,7 @@ public static string GetString(uint strId)
if ((Get-Service -Name EventLog).Status -eq "Stopped") if ((Get-Service -Name EventLog).Status -eq "Stopped")
{ {
# Extract the localized "Event Viewer" string from shell32.dll # 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://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79" Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -431,6 +452,7 @@ public static string GetString(uint strId)
try try
{ {
$Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
Get-Service -Name SecurityHealthService -ErrorAction Stop | Start-Service
} }
catch [Microsoft.PowerShell.Commands.ServiceCommandException] catch [Microsoft.PowerShell.Commands.ServiceCommandException]
{ {
@ -676,7 +698,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker # Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker
@ -766,7 +788,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Check whether hosts contains any of string from $IPArray array # Check whether hosts contains any of string from $IPArray array
@ -806,6 +828,34 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue 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 # 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 Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
@ -857,7 +907,7 @@ public static string GetString(uint strId)
if ($AddSkip) if ($AddSkip)
{ {
# Extract the localized "Skip" string from shell32.dll # 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 # https://github.com/microsoft/terminal/issues/14992
@ -912,14 +962,14 @@ public static string GetString(uint strId)
} }
# Extract the localized "Browse" string from shell32.dll # 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 # 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 # 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) $Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
# Extract the localized "Skip" string from shell32.dll # 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 # Display a warning message about whether a user has customized the preset file
if ($Warning) if ($Warning)
@ -1141,7 +1191,7 @@ function DiagTrackService
) )
# Check whether "InitialActions" function was removed in preset file # 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 # Get the name of a preset (e.g Sophia.ps1) regardless it was named
# $_.File has no EndsWith() method # $_.File has no EndsWith() method
@ -1564,7 +1614,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1576,7 +1626,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1629,7 +1679,7 @@ function ScheduledTasks
{ {
$State = "Disabled" $State = "Disabled"
# Extract the localized "Enable" string from shell32.dll # Extract the localized "Enable" string from shell32.dll
$ButtonContent = [WinAPI.GetStr]::GetString(51472) $ButtonContent = [WinAPI.GetStrings]::GetString(51472)
$ButtonAdd_Click = {EnableButton} $ButtonAdd_Click = {EnableButton}
} }
"Disable" "Disable"
@ -1642,7 +1692,7 @@ function ScheduledTasks
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all scheduled tasks according to the conditions
$Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)} $Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)}
@ -3568,7 +3618,7 @@ function UnpinTaskbarShortcuts
) )
# Extract the localized "Unpin from taskbar" string from shell32.dll # Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387) $LocalizedString = [WinAPI.GetStrings]::GetString(5387)
foreach ($Shortcut in $Shortcuts) foreach ($Shortcut in $Shortcuts)
{ {
@ -3582,7 +3632,7 @@ function UnpinTaskbarShortcuts
$Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar") $Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk") $Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll # 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 Store
@ -5857,7 +5907,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5869,7 +5919,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5939,7 +5989,7 @@ function WindowsFeatures
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all optional features according to the conditions
$OFS = "|" $OFS = "|"
@ -6212,7 +6262,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6230,7 +6280,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6329,7 +6379,7 @@ function WindowsCapabilities
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all capabilities according to the conditions
$OFS = "|" $OFS = "|"
@ -6756,7 +6806,7 @@ function NetworkAdaptersSavePower
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{ {
@ -6796,7 +6846,7 @@ function NetworkAdaptersSavePower
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Start-Sleep -Seconds 2
} }
@ -6859,7 +6909,7 @@ function IPv6Component
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -7226,10 +7276,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7254,10 +7304,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7282,10 +7332,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7310,10 +7360,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7338,10 +7388,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7366,10 +7416,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7396,10 +7446,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7436,10 +7486,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7476,10 +7526,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7516,10 +7566,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7556,10 +7606,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7596,10 +7646,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7638,11 +7688,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Desktop" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7667,11 +7717,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Documents" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7696,11 +7746,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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 # 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7725,11 +7775,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Music" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7754,11 +7804,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7783,11 +7833,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -9360,7 +9410,7 @@ public static long MakeLong(uint left, uint right)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Register %1 argument if ProgId exists as an executable file
if (Test-Path -Path $ProgramPath) if (Test-Path -Path $ProgramPath)
@ -10749,14 +10799,14 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
#> #>
function UnpinAllStartApps function UnpinAllStartApps
{ {
Remove-Item "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start*.bin" -Force -ErrorAction Ignore Remove-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start*.bin" -Force -ErrorAction Ignore
# https://gist.github.com/rad1ke # https://gist.github.com/rad1ke
$HexString = "E27AE14B01FC4D1B9C00810BDE6E51854E5A5F47005BB1498A5C92AF9084F95E9BDB91E2EEDDD701300B000067DEFA31529529B3D32D8092A6EB66C8D5EADB19CF9B13518AAB9 $HexString = "E27AE14B01FC4D1B9C00810BDE6E51854E5A5F47005BB1498A5C92AF9084F95E9BDB91E2EEDDD701300B000067DEFA31529529B3D32D8092A6EB66C8D5EADB19CF9B13518AAB9
3275D9CEEF37E62C3574C036F327D1110AB0977996D67A2F8FA897D7207BEE85586B8CE6AD4F9736AA2154E3DCC9D082996984B76F1C73067F124F92A41F2B2CA83EF35436670979556FAE85AB10EA1 3275D9CEEF37E62C3574C036F327D1110AB0977996D67A2F8FA897D7207BEE85586B8CE6AD4F9736AA2154E3DCC9D082996984B76F1C73067F124F92A41F2B2CA83EF35436670979556FAE85AB10EA1
6C932C3AECE1D45DA06D64BC42F4565AD0FCB8C63CDE7F6BB97ACE300198C3EACA3E1C974F547B1A7CF5B9C6A912448AB38A3BE2D6F0230A4A9AACC710C3E75088754CC2FB054B55B1D6ED7AD41EB8B 6C932C3AECE1D45DA06D64BC42F4565AD0FCB8C63CDE7F6BB97ACE300198C3EACA3E1C974F547B1A7CF5B9C6A912448AB38A3BE2D6F0230A4A9AACC710C3E75088754CC2FB054B55B1D6ED7AD41EB8B
0C9D4C274E87A525582F6CFBEAE5A904A1B0A3BA07939B79CAB4F1C3DF35BF88DE846E64555F0AEB47562C329206A9975664558849E0C251E8832D52B4FD7560347E5606AC882B9FC1F43C96922C0EA 0C9D4C274E87A525582F6CFBEAE5A904A1B0A3BA07939B79CAB4F1C3DF35BF88DE846E64555F0AEB47562C329206A9975664558849E0C251E8832D52B4FD7560347E5606AC882B9FC1F43C96922C0EA
1927DF004A062BAD5AC5A4BE6BF2DB23158B2BAEEF8DE9E3A777910E82E5488A83E4D64B0D84440B98B35BC4A3438596145669904AB392CFD5F7E22F616747B85206481FE1FF41CA9A2534CCE7AFC45 1927DF004A062BAD5AC5A4BE6BF2DB23158B2BAEEF8DE9E3A777910E82E5488A83E4D64B0D84440B98B35BC4A3438596145669904AB392CFD5F7E22F616747B84851481FE1FF41CA9A2534CCE7AFC45
584370B4940DF30555536344249690F00C3A7E2552E352FE733C7ED2F80A29AD16937810AF805A444A344188C0CBDA51E5466BF45F2587508A69581CC2BCDAE06CB363658D94CD60569352FDA17AE7C 584370B4940DF30555536344249690F00C3A7E2552E352FE733C7ED2F80A29AD16937810AF805A444A344188C0CBDA51E5466BF45F2587508A69581CC2BCDAE06CB363658D94CD60569352FDA17AE7C
DD785810F369B41F2D15930430A809567CC6C643FE7986CAD545EF3DB40CA6FA9220BFC7F65610AECB22799838B80DE73AF549923F8219FFAAD64780E2DB53133D73890294E77F9B0970484E86A0507 DD785810F369B41F2D15930430A809567CC6C643FE7986CAD545EF3DB40CA6FA9220BFC7F65610AECB22799838B80DE73AF549923F8219FFAAD64780E2DB53133D73890294E77F9B0970484E86A0507
37724FF15281C1726D334D3C9A67A85A78AE33F55DB675DAA31C47A156C0F8212DCEE228537668F4BF898C0CB869B74C98DF7EFBE0130859E5156417A85CC634B86314FAB47FB9A8DFEAFA1AEFC5E59 37724FF15281C1726D334D3C9A67A85A78AE33F55DB675DAA31C47A156C0F8212DCEE228537668F4BF898C0CB869B74C98DF7EFBE0130859E5156417A85CC634B86314FAB47FB9A8DFEAFA1AEFC5E59
@ -10784,7 +10834,7 @@ FEA494190BF3446DCC8C8AAF62BA01F0BFB18E15503C27558DB70C48EFB0AEA0B600F985C904E9F2
2EEEF7B09850D29B2F412DEF3D0BD9194CAE8113B3B38085C77C238CB8D15BF6D6AB42C193F4E2F27F8BEDABB2D6ADE9E486B6AFAFD8D5DBE3B7D7305790F96ECDCC2DD016C5B9B200CB72E6CF54D71 2EEEF7B09850D29B2F412DEF3D0BD9194CAE8113B3B38085C77C238CB8D15BF6D6AB42C193F4E2F27F8BEDABB2D6ADE9E486B6AFAFD8D5DBE3B7D7305790F96ECDCC2DD016C5B9B200CB72E6CF54D71
F69A01CDE4E3A0A4C5A03627DECD491F215C1420EB07AB8FD2763FCFF5211EB964C82E69DA208BDFA76306D54642B117DCB9A92927CE2E633338D4EEA63B571349B8DA1D4B5523C4CA10308769E4F46 F69A01CDE4E3A0A4C5A03627DECD491F215C1420EB07AB8FD2763FCFF5211EB964C82E69DA208BDFA76306D54642B117DCB9A92927CE2E633338D4EEA63B571349B8DA1D4B5523C4CA10308769E4F46
1ADD16DD5DFDB0E705187593DEF5CCCF659E48366462CC21D7930E1064234157A7A08E9C90927A37C5CF23D54C755002E4E657BB6E70D9B4BE7C468C19D6969FAE138EBF2C20DD3F5A0BC4C0E97D5BF 1ADD16DD5DFDB0E705187593DEF5CCCF659E48366462CC21D7930E1064234157A7A08E9C90927A37C5CF23D54C755002E4E657BB6E70D9B4BE7C468C19D6969FAE138EBF2C20DD3F5A0BC4C0E97D5BF
DB8744A21396C44549308517BEAD5AE14FF602E69E75B87784DE5F30BE14106E8D8A081DC8CCCFBF93896E622F755F27E82A596DDCA3469A93ECB9E2E897BF0FCC063426DACDC3B1D81E1EFE6B63932 DB8744A21396C44549242817BEAD5AE14FF602E69E75B87784DE5F30BE14106E8D8A081DC8CCCFBF93896E622F755F27E82A596DDCA3469A93ECB9E2E897BF0FCC063426DACDC3B1D81E1EFE6B63932
6CA43526CFAEDF9922EAC3204FEB84AAED781EE5516FA5B4DCAB85DB5FF33CEC454DAA375BDA5EEA7C871C310AEDC5BD6B220B59B901D377E22FFFE95FEDA28CE2CE33CAEB8541EE05E1B5650D776C4 6CA43526CFAEDF9922EAC3204FEB84AAED781EE5516FA5B4DCAB85DB5FF33CEC454DAA375BDA5EEA7C871C310AEDC5BD6B220B59B901D377E22FFFE95FEDA28CE2CE33CAEB8541EE05E1B5650D776C4
B2A246DB4613E2CC5D96A44D24AE662D848A7C9E3E922AFF0632B7B40505402956FABC5C3AAB55EEE29085046C127E8776CEFC1690B76EE99371AF9B1D7EF6F79E78325DD3BD8377E9B73B936C6F261 B2A246DB4613E2CC5D96A44D24AE662D848A7C9E3E922AFF0632B7B40505402956FABC5C3AAB55EEE29085046C127E8776CEFC1690B76EE99371AF9B1D7EF6F79E78325DD3BD8377E9B73B936C6F261
1D0A1223A4D7C6CF3037922DD0686A701FF86761993F294D26E13A7BB8B1C61ACAF38D50334A88DABB3FA412B4FC79F6FBFD0D0A92301484FF1BD1CF3DC67780E4562E05CCA329CABA7CB2B77D9A707 1D0A1223A4D7C6CF3037922DD0686A701FF86761993F294D26E13A7BB8B1C61ACAF38D50334A88DABB3FA412B4FC79F6FBFD0D0A92301484FF1BD1CF3DC67780E4562E05CCA329CABA7CB2B77D9A707
@ -10793,12 +10843,10 @@ BDEE24B1E5E4ED6CC9D5A337908BE5303E477736C8A75051A8FBD4E3CB6360D8F0A992A48F333434
$HexString = $HexString.Replace("`n","").Replace("`r","") $HexString = $HexString.Replace("`n","").Replace("`r","")
$Bytes = [byte[]]::new($HexString.Length/2) $Bytes = [byte[]]::new($HexString.Length/2)
for for ($i = 0; $i -lt $HexString.Length; $i += 2)
( {
$i = 0 $Bytes[$i/2] = [System.Convert]::ToByte($HexString.Substring($i, 2), 16)
$i -lt $HexString.Length }
$i += 2
)
{ {
$Bytes[$i/2] = [System.Convert]::ToByte($HexString.Substring($i, 2), 16) $Bytes[$i/2] = [System.Convert]::ToByte($HexString.Substring($i, 2), 16)
} }
@ -11096,7 +11144,7 @@ function UninstallUWPApps
$ButtonUninstall.Content = $Localization.Uninstall $ButtonUninstall.Content = $Localization.Uninstall
$TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll $TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonUninstall.Add_Click({ButtonUninstallClick})
$CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick}) $CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick})
@ -11118,7 +11166,7 @@ function UninstallUWPApps
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
@ -11229,7 +11277,7 @@ function UninstallUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -11470,7 +11518,7 @@ function RestoreUWPApps
$Window.Title = $Localization.UWPAppsTitle $Window.Title = $Localization.UWPAppsTitle
$ButtonRestore.Content = $Localization.Restore $ButtonRestore.Content = $Localization.Restore
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonRestore.Add_Click({ButtonRestoreClick})
$CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick}) $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
@ -11481,7 +11529,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # 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 $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
@ -11563,7 +11611,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -12420,7 +12468,7 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action content="$([WinAPI.GetStr]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/> <action content="$([WinAPI.GetStrings]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/>
<action content="" arguments="dismiss" activationType="system"/> <action content="" arguments="dismiss" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -14998,7 +15046,7 @@ function UpdateLGPEPolicies
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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.GPOUpdate -Verbose Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Verbose -Message HKLM -Verbose Write-Verbose -Message HKLM -Verbose
@ -15285,7 +15333,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15313,7 +15361,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophianews" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophianews" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15341,7 +15389,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15357,7 +15405,7 @@ public static void PostMessage()
# Check for UWP apps updates # Check for UWP apps updates
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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
Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod
} }
@ -15378,7 +15426,7 @@ function Errors
[PSCustomObject]@{ [PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber $Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll # Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStr]::GetString(4130))" = $ErrorInFile "$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message $Localization.ErrorsMessage = $_.Exception.Message
} }
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim() } | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()

241
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -58,9 +58,10 @@ function InitialActions
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Extract strings from %SystemRoot%\System32\shell32.dll using its' number # 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 = @{ $Signature = @{
Namespace = "WinAPI" Namespace = "WinAPI"
Name = "GetStr" Name = "GetStrings"
Language = "CSharp" Language = "CSharp"
UsingNamespace = "System.Text" UsingNamespace = "System.Text"
MemberDefinition = @" MemberDefinition = @"
@ -77,9 +78,38 @@ public static string GetString(uint strId)
LoadString(intPtr, strId, sb, sb.Capacity); LoadString(intPtr, strId, sb, sb.Capacity);
return sb.ToString(); 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]))
{ {
Add-Type @Signature Add-Type @Signature
} }
@ -89,7 +119,7 @@ public static string GetString(uint strId)
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -140,16 +170,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 & "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
} }
catch [System.InvalidOperationException] catch
{
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]
{ {
Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge") Write-Warning -Message ($Localization.WindowsComponentBroken -f "Microsoft Edge")
@ -329,7 +350,7 @@ public static string GetString(uint strId)
if ((Get-Service -Name EventLog).Status -eq "Stopped") if ((Get-Service -Name EventLog).Status -eq "Stopped")
{ {
# Extract the localized "Event Viewer" string from shell32.dll # 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://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79" Start-Process -FilePath "https://discord.gg/sSryhaEv79"
@ -412,6 +433,7 @@ public static string GetString(uint strId)
try try
{ {
$Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop $Services = Get-Service -Name Windefend, SecurityHealthService, wscsvc -ErrorAction Stop
Get-Service -Name SecurityHealthService -ErrorAction Stop | Start-Service
} }
catch [Microsoft.PowerShell.Commands.ServiceCommandException] catch [Microsoft.PowerShell.Commands.ServiceCommandException]
{ {
@ -662,7 +684,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker # Remove IP addresses from hosts file that block Microsoft recourses added by WindowsSpyBlocker
@ -752,7 +774,7 @@ public static string GetString(uint strId)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Write-Information -MessageData "" -InformationAction Continue
# Check whether hosts contains any of string from $IPArray array # Check whether hosts contains any of string from $IPArray array
@ -792,6 +814,33 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue 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 = "SophiaTest"
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
}
Unregister-ScheduledTask -TaskName SophiaTest -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 # 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 Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
@ -843,7 +892,7 @@ public static string GetString(uint strId)
if ($AddSkip) if ($AddSkip)
{ {
# Extract the localized "Skip" string from shell32.dll # 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 # https://github.com/microsoft/terminal/issues/14992
@ -898,14 +947,14 @@ public static string GetString(uint strId)
} }
# Extract the localized "Browse" string from shell32.dll # 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 # 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 # 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) $Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
# Extract the localized "Skip" string from shell32.dll # 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 # Display a warning message about whether a user has customized the preset file
if ($Warning) if ($Warning)
@ -1127,7 +1176,7 @@ function DiagTrackService
) )
# Check whether "InitialActions" function was removed in preset file # 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 # Get the name of a preset (e.g Sophia.ps1) regardless it was named
# $_.File has no EndsWith() method # $_.File has no EndsWith() method
@ -1550,7 +1599,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1562,7 +1611,7 @@ function ScheduledTasks
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -1615,7 +1664,7 @@ function ScheduledTasks
{ {
$State = "Disabled" $State = "Disabled"
# Extract the localized "Enable" string from shell32.dll # Extract the localized "Enable" string from shell32.dll
$ButtonContent = [WinAPI.GetStr]::GetString(51472) $ButtonContent = [WinAPI.GetStrings]::GetString(51472)
$ButtonAdd_Click = {EnableButton} $ButtonAdd_Click = {EnableButton}
} }
"Disable" "Disable"
@ -1628,7 +1677,7 @@ function ScheduledTasks
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all scheduled tasks according to the conditions
$Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)} $Tasks = Get-ScheduledTask | Where-Object -FilterScript {($_.State -eq $State) -and ($_.TaskName -in $CheckedScheduledTasks)}
@ -3554,7 +3603,7 @@ function UnpinTaskbarShortcuts
) )
# Extract the localized "Unpin from taskbar" string from shell32.dll # Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387) $LocalizedString = [WinAPI.GetStrings]::GetString(5387)
foreach ($Shortcut in $Shortcuts) foreach ($Shortcut in $Shortcuts)
{ {
@ -3568,7 +3617,7 @@ function UnpinTaskbarShortcuts
$Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar") $Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk") $Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll # 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 Store
@ -5843,7 +5892,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5855,7 +5904,7 @@ function WindowsFeatures
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -5925,7 +5974,7 @@ function WindowsFeatures
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all optional features according to the conditions
$OFS = "|" $OFS = "|"
@ -6198,7 +6247,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6216,7 +6265,7 @@ function WindowsCapabilities
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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() [void]$Window.Close()
@ -6315,7 +6364,7 @@ function WindowsCapabilities
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Getting list of all capabilities according to the conditions
$OFS = "|" $OFS = "|"
@ -6742,7 +6791,7 @@ function NetworkAdaptersSavePower
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) if (Get-NetAdapter -Physical | Where-Object -FilterScript {($_.Status -eq "Up") -and $_.MacAddress})
{ {
@ -6782,7 +6831,7 @@ function NetworkAdaptersSavePower
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 Start-Sleep -Seconds 2
} }
@ -6845,7 +6894,7 @@ function IPv6Component
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 try
{ {
@ -7212,10 +7261,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7240,10 +7289,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7268,10 +7317,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7296,10 +7345,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7324,10 +7373,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7352,10 +7401,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7382,10 +7431,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7422,10 +7471,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7462,10 +7511,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7502,10 +7551,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7542,10 +7591,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7582,10 +7631,10 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7624,11 +7673,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
{ {
# Desktop # Desktop
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Desktop" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7653,11 +7702,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Documents # Documents
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Documents" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7682,11 +7731,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Downloads # Downloads
Write-Information -MessageData "" -InformationAction Continue 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 # 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}" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7711,11 +7760,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Music # Music
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Music" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7740,11 +7789,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Pictures # Pictures
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -7769,11 +7818,11 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
# Videos # Videos
Write-Information -MessageData "" -InformationAction Continue 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 # Extract the localized "Pictures" string from shell32.dll
$CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" $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 Write-Warning -Message $Localization.FilesWontBeMoved
do do
@ -9346,7 +9395,7 @@ public static long MakeLong(uint left, uint right)
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # Register %1 argument if ProgId exists as an executable file
if (Test-Path -Path $ProgramPath) if (Test-Path -Path $ProgramPath)
@ -10733,14 +10782,14 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
#> #>
function UnpinAllStartApps function UnpinAllStartApps
{ {
Remove-Item "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start*.bin" -Force -ErrorAction Ignore Remove-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start*.bin" -Force -ErrorAction Ignore
# https://gist.github.com/rad1ke # https://gist.github.com/rad1ke
$HexString = "E27AE14B01FC4D1B9C00810BDE6E51854E5A5F47005BB1498A5C92AF9084F95E9BDB91E2EEDDD701300B000067DEFA31529529B3D32D8092A6EB66C8D5EADB19CF9B13518AAB9 $HexString = "E27AE14B01FC4D1B9C00810BDE6E51854E5A5F47005BB1498A5C92AF9084F95E9BDB91E2EEDDD701300B000067DEFA31529529B3D32D8092A6EB66C8D5EADB19CF9B13518AAB9
3275D9CEEF37E62C3574C036F327D1110AB0977996D67A2F8FA897D7207BEE85586B8CE6AD4F9736AA2154E3DCC9D082996984B76F1C73067F124F92A41F2B2CA83EF35436670979556FAE85AB10EA1 3275D9CEEF37E62C3574C036F327D1110AB0977996D67A2F8FA897D7207BEE85586B8CE6AD4F9736AA2154E3DCC9D082996984B76F1C73067F124F92A41F2B2CA83EF35436670979556FAE85AB10EA1
6C932C3AECE1D45DA06D64BC42F4565AD0FCB8C63CDE7F6BB97ACE300198C3EACA3E1C974F547B1A7CF5B9C6A912448AB38A3BE2D6F0230A4A9AACC710C3E75088754CC2FB054B55B1D6ED7AD41EB8B 6C932C3AECE1D45DA06D64BC42F4565AD0FCB8C63CDE7F6BB97ACE300198C3EACA3E1C974F547B1A7CF5B9C6A912448AB38A3BE2D6F0230A4A9AACC710C3E75088754CC2FB054B55B1D6ED7AD41EB8B
0C9D4C274E87A525582F6CFBEAE5A904A1B0A3BA07939B79CAB4F1C3DF35BF88DE846E64555F0AEB47562C329206A9975664558849E0C251E8832D52B4FD7560347E5606AC882B9FC1F43C96922C0EA 0C9D4C274E87A525582F6CFBEAE5A904A1B0A3BA07939B79CAB4F1C3DF35BF88DE846E64555F0AEB47562C329206A9975664558849E0C251E8832D52B4FD7560347E5606AC882B9FC1F43C96922C0EA
1927DF004A062BAD5AC5A4BE6BF2DB23158B2BAEEF8DE9E3A777910E82E5488A83E4D64B0D84440B98B35BC4A3438596145669904AB392CFD5F7E22F616747B85206481FE1FF41CA9A2534CCE7AFC45 1927DF004A062BAD5AC5A4BE6BF2DB23158B2BAEEF8DE9E3A777910E82E5488A83E4D64B0D84440B98B35BC4A3438596145669904AB392CFD5F7E22F616747B84851481FE1FF41CA9A2534CCE7AFC45
584370B4940DF30555536344249690F00C3A7E2552E352FE733C7ED2F80A29AD16937810AF805A444A344188C0CBDA51E5466BF45F2587508A69581CC2BCDAE06CB363658D94CD60569352FDA17AE7C 584370B4940DF30555536344249690F00C3A7E2552E352FE733C7ED2F80A29AD16937810AF805A444A344188C0CBDA51E5466BF45F2587508A69581CC2BCDAE06CB363658D94CD60569352FDA17AE7C
DD785810F369B41F2D15930430A809567CC6C643FE7986CAD545EF3DB40CA6FA9220BFC7F65610AECB22799838B80DE73AF549923F8219FFAAD64780E2DB53133D73890294E77F9B0970484E86A0507 DD785810F369B41F2D15930430A809567CC6C643FE7986CAD545EF3DB40CA6FA9220BFC7F65610AECB22799838B80DE73AF549923F8219FFAAD64780E2DB53133D73890294E77F9B0970484E86A0507
37724FF15281C1726D334D3C9A67A85A78AE33F55DB675DAA31C47A156C0F8212DCEE228537668F4BF898C0CB869B74C98DF7EFBE0130859E5156417A85CC634B86314FAB47FB9A8DFEAFA1AEFC5E59 37724FF15281C1726D334D3C9A67A85A78AE33F55DB675DAA31C47A156C0F8212DCEE228537668F4BF898C0CB869B74C98DF7EFBE0130859E5156417A85CC634B86314FAB47FB9A8DFEAFA1AEFC5E59
@ -10768,7 +10817,7 @@ FEA494190BF3446DCC8C8AAF62BA01F0BFB18E15503C27558DB70C48EFB0AEA0B600F985C904E9F2
2EEEF7B09850D29B2F412DEF3D0BD9194CAE8113B3B38085C77C238CB8D15BF6D6AB42C193F4E2F27F8BEDABB2D6ADE9E486B6AFAFD8D5DBE3B7D7305790F96ECDCC2DD016C5B9B200CB72E6CF54D71 2EEEF7B09850D29B2F412DEF3D0BD9194CAE8113B3B38085C77C238CB8D15BF6D6AB42C193F4E2F27F8BEDABB2D6ADE9E486B6AFAFD8D5DBE3B7D7305790F96ECDCC2DD016C5B9B200CB72E6CF54D71
F69A01CDE4E3A0A4C5A03627DECD491F215C1420EB07AB8FD2763FCFF5211EB964C82E69DA208BDFA76306D54642B117DCB9A92927CE2E633338D4EEA63B571349B8DA1D4B5523C4CA10308769E4F46 F69A01CDE4E3A0A4C5A03627DECD491F215C1420EB07AB8FD2763FCFF5211EB964C82E69DA208BDFA76306D54642B117DCB9A92927CE2E633338D4EEA63B571349B8DA1D4B5523C4CA10308769E4F46
1ADD16DD5DFDB0E705187593DEF5CCCF659E48366462CC21D7930E1064234157A7A08E9C90927A37C5CF23D54C755002E4E657BB6E70D9B4BE7C468C19D6969FAE138EBF2C20DD3F5A0BC4C0E97D5BF 1ADD16DD5DFDB0E705187593DEF5CCCF659E48366462CC21D7930E1064234157A7A08E9C90927A37C5CF23D54C755002E4E657BB6E70D9B4BE7C468C19D6969FAE138EBF2C20DD3F5A0BC4C0E97D5BF
DB8744A21396C44549308517BEAD5AE14FF602E69E75B87784DE5F30BE14106E8D8A081DC8CCCFBF93896E622F755F27E82A596DDCA3469A93ECB9E2E897BF0FCC063426DACDC3B1D81E1EFE6B63932 DB8744A21396C44549242817BEAD5AE14FF602E69E75B87784DE5F30BE14106E8D8A081DC8CCCFBF93896E622F755F27E82A596DDCA3469A93ECB9E2E897BF0FCC063426DACDC3B1D81E1EFE6B63932
6CA43526CFAEDF9922EAC3204FEB84AAED781EE5516FA5B4DCAB85DB5FF33CEC454DAA375BDA5EEA7C871C310AEDC5BD6B220B59B901D377E22FFFE95FEDA28CE2CE33CAEB8541EE05E1B5650D776C4 6CA43526CFAEDF9922EAC3204FEB84AAED781EE5516FA5B4DCAB85DB5FF33CEC454DAA375BDA5EEA7C871C310AEDC5BD6B220B59B901D377E22FFFE95FEDA28CE2CE33CAEB8541EE05E1B5650D776C4
B2A246DB4613E2CC5D96A44D24AE662D848A7C9E3E922AFF0632B7B40505402956FABC5C3AAB55EEE29085046C127E8776CEFC1690B76EE99371AF9B1D7EF6F79E78325DD3BD8377E9B73B936C6F261 B2A246DB4613E2CC5D96A44D24AE662D848A7C9E3E922AFF0632B7B40505402956FABC5C3AAB55EEE29085046C127E8776CEFC1690B76EE99371AF9B1D7EF6F79E78325DD3BD8377E9B73B936C6F261
1D0A1223A4D7C6CF3037922DD0686A701FF86761993F294D26E13A7BB8B1C61ACAF38D50334A88DABB3FA412B4FC79F6FBFD0D0A92301484FF1BD1CF3DC67780E4562E05CCA329CABA7CB2B77D9A707 1D0A1223A4D7C6CF3037922DD0686A701FF86761993F294D26E13A7BB8B1C61ACAF38D50334A88DABB3FA412B4FC79F6FBFD0D0A92301484FF1BD1CF3DC67780E4562E05CCA329CABA7CB2B77D9A707
@ -10777,17 +10826,15 @@ BDEE24B1E5E4ED6CC9D5A337908BE5303E477736C8A75051A8FBD4E3CB6360D8F0A992A48F333434
$HexString = $HexString.Replace("`n","").Replace("`r","") $HexString = $HexString.Replace("`n","").Replace("`r","")
$Bytes = [byte[]]::new($HexString.Length/2) $Bytes = [byte[]]::new($HexString.Length/2)
for for ($i = 0; $i -lt $HexString.Length; $i += 2)
( {
$i = 0 $Bytes[$i/2] = [System.Convert]::ToByte($HexString.Substring($i, 2), 16)
$i -lt $HexString.Length }
$i += 2
)
{ {
$Bytes[$i/2] = [System.Convert]::ToByte($HexString.Substring($i, 2), 16) $Bytes[$i/2] = [System.Convert]::ToByte($HexString.Substring($i, 2), 16)
} }
Set-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start2.bin" -Value $Bytes -AsByteStream -Force Set-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start2.bin" -Value $Bytes -Encoding Byte -Force
} }
<# <#
@ -11090,7 +11137,7 @@ function UninstallUWPApps
$ButtonUninstall.Content = $Localization.Uninstall $ButtonUninstall.Content = $Localization.Uninstall
$TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll $TextBlockRemoveForAll.Text = $Localization.UninstallUWPForAll
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonUninstall.Add_Click({ButtonUninstallClick})
$CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick}) $CheckBoxForAllUsers.Add_Click({CheckBoxForAllUsersClick})
@ -11112,7 +11159,7 @@ function UninstallUWPApps
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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}) $AppxPackages = @(Get-AppxPackage -PackageTypeFilter Bundle -AllUsers:$AllUsers | Where-Object -FilterScript {$_.Name -notin $ExcludedAppxPackages})
@ -11223,7 +11270,7 @@ function UninstallUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -11474,7 +11521,7 @@ function RestoreUWPApps
$Window.Title = $Localization.UWPAppsTitle $Window.Title = $Localization.UWPAppsTitle
$ButtonRestore.Content = $Localization.Restore $ButtonRestore.Content = $Localization.Restore
# Extract the localized "Select all" string from shell32.dll # 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}) $ButtonRestore.Add_Click({ButtonRestoreClick})
$CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick}) $CheckBoxSelectAll.Add_Click({CheckBoxSelectAllClick})
@ -11485,7 +11532,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 # 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 $Bundles = (Get-AppXPackage -PackageTypeFilter Bundle -AllUsers).Name
@ -11567,7 +11614,7 @@ function RestoreUWPApps
{ {
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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 $Window.Close() | Out-Null
@ -12424,7 +12471,7 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action content="$([WinAPI.GetStr]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/> <action content="$([WinAPI.GetStrings]::GetString(12850))" arguments="WindowsCleanup:" activationType="protocol"/>
<action content="" arguments="dismiss" activationType="system"/> <action content="" arguments="dismiss" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15002,7 +15049,7 @@ function UpdateLGPEPolicies
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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.GPOUpdate -Verbose Write-Verbose -Message $Localization.GPOUpdate -Verbose
Write-Verbose -Message HKLM -Verbose Write-Verbose -Message HKLM -Verbose
@ -15289,7 +15336,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophia_chat" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15317,7 +15364,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://t.me/sophianews" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://t.me/sophianews" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15345,7 +15392,7 @@ public static void PostMessage()
</visual> </visual>
<audio src="ms-winsoundevent:notification.default" /> <audio src="ms-winsoundevent:notification.default" />
<actions> <actions>
<action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStr]::GetString(12850))" activationType="protocol"/> <action arguments="https://discord.gg/sSryhaEv79" content="$([WinAPI.GetStrings]::GetString(12850))" activationType="protocol"/>
<action arguments="dismiss" content="" activationType="system"/> <action arguments="dismiss" content="" activationType="system"/>
</actions> </actions>
</toast> </toast>
@ -15361,7 +15408,7 @@ public static void PostMessage()
# Check for UWP apps updates # Check for UWP apps updates
Write-Information -MessageData "" -InformationAction Continue Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll # 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
Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod Get-CimInstance -Namespace root/CIMV2/mdm/dmmap -ClassName MDM_EnterpriseModernAppManagement_AppManagement01 | Invoke-CimMethod -MethodName UpdateScanMethod
} }
@ -15382,7 +15429,7 @@ function Errors
[PSCustomObject]@{ [PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber $Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll # Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStr]::GetString(4130))" = $ErrorInFile "$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message $Localization.ErrorsMessage = $_.Exception.Message
} }
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim() } | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()

Loading…
Cancel
Save