@ -5,8 +5,7 @@
Version : v5 . 18 . 2
Version : v5 . 18 . 2
Date : 06 . 03 . 2024
Date : 06 . 03 . 2024
Copyright ( c ) 2014 — 2024 farag
Copyright ( c ) 2014 — 2024 farag , Inestic & lowl1f3
Copyright ( c ) 2019 — 2024 farag & Inestic
Thanks to all https : / / forum . ru-board . com members involved
Thanks to all https : / / forum . ru-board . com members involved
@ -36,6 +35,7 @@
. LINK Authors
. LINK Authors
https : / / github . com / farag2
https : / / github . com / farag2
https : / / github . com / Inestic
https : / / github . com / Inestic
https : / / github . com / lowl1f3
#>
#>
#region InitialActions
#region InitialActions
@ -64,6 +64,7 @@ function InitialActions
# 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
# https://github.com/SamuelArnold/StarKill3r/blob/master/Star%20Killer/Star%20Killer/bin/Debug/Scripts/SANS-SEC505-master/scripts/Day1-PowerShell/Expand-IndirectString.ps1
# [WinAPI.GetStrings]::GetIndirectString("@%SystemRoot%\system32\schedsvc.dll,-100")
$Signature = @ {
$Signature = @ {
Namespace = " WinAPI "
Namespace = " WinAPI "
Name = " GetStrings "
Name = " GetStrings "
@ -841,33 +842,6 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
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://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
# https://github.com/PowerShell/PowerShell/issues/21070
# https://github.com/PowerShell/PowerShell/issues/21070
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
@ -5648,10 +5622,12 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
" @
" @
# Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
# Create a temporary scheduled task to create a symbolic link to the %SystemDrive%\Temp folder
# We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
# https://github.com/PowerShell/PowerShell/issues/21377
$Action = New-ScheduledTaskAction -Execute powershell . exe -Argument " -WindowStyle Hidden -Command $ SymbolicLinkTask "
$Action = New-ScheduledTaskAction -Execute powershell . exe -Argument " -WindowStyle Hidden -Command $ SymbolicLinkTask "
$Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
$Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Principal = New-ScheduledTaskPrincipal -UserId " $ env:COMPUTERNAME\ $ env:USERNAME" -RunLevel Highest
$Parameters = @ {
$Parameters = @ {
TaskName = " SymbolicLink "
TaskName = " SymbolicLink "
Principal = $Principal
Principal = $Principal
@ -5770,10 +5746,12 @@ Unregister-ScheduledTask -TaskName TemporaryTask -Confirm:`$false
" @
" @
# Create a temporary scheduled task to clean up the temporary folder
# Create a temporary scheduled task to clean up the temporary folder
# We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
# https://github.com/PowerShell/PowerShell/issues/21377
$Action = New-ScheduledTaskAction -Execute powershell . exe -Argument " -WindowStyle Hidden -Command $ TempFolderCleanupTask "
$Action = New-ScheduledTaskAction -Execute powershell . exe -Argument " -WindowStyle Hidden -Command $ TempFolderCleanupTask "
$Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
$Trigger = New-ScheduledTaskTrigger -AtLogon -User $env:USERNAME
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Principal = New-ScheduledTaskPrincipal -UserId " $ env:COMPUTERNAME\ $ env:USERNAME" -RunLevel Highest
$Parameters = @ {
$Parameters = @ {
TaskName = " TemporaryTask "
TaskName = " TemporaryTask "
Principal = $Principal
Principal = $Principal
@ -10213,15 +10191,18 @@ function InstallVCRedist
return
return
}
}
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore ) . Version -ge [System.Version] " 1.17 " )
if ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore )
{
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/VCRedist/2015%2B
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller ) . Version -ge [System.Version] " 1.17 " )
winget install - -id = Microsoft . VCRedist . 2015 + . x86 - -exact - -force - -accept -source -agreements
{
winget install - -id = Microsoft . VCRedist . 2015 + . x64 - -exact - -force - -accept -source -agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/VCRedist/2015%2B
winget install - -id = Microsoft . VCRedist . 2015 + . x86 - -exact - -force - -accept -source -agreements
winget install - -id = Microsoft . VCRedist . 2015 + . x64 - -exact - -force - -accept -source -agreements
# 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
# https://github.com/PowerShell/PowerShell/issues/21070
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
else
else
{
{
@ -10268,10 +10249,10 @@ function InstallVCRedist
<#
<#
. SYNOPSIS
. SYNOPSIS
Install the latest . NET Desktop Runtime 6 , 7 , 8 x64
Install the latest . NET Desktop Runtime 6 , 8 x64
. EXAMPLE
. EXAMPLE
InstallDotNetRuntimes -Runtimes NET6x64 , NET7x64 , NET 8x64
InstallDotNetRuntimes -Runtimes NET6x64 , NET8x64
. LINK
. LINK
https : / / dotnet . microsoft . com / en-us / download / dotnet
https : / / dotnet . microsoft . com / en-us / download / dotnet
@ -10288,7 +10269,7 @@ function InstallDotNetRuntimes
Mandatory = $true ,
Mandatory = $true ,
ParameterSetName = " Runtimes "
ParameterSetName = " Runtimes "
) ]
) ]
[ ValidateSet ( " NET6x64 " , " NET7x64 " , " NET 8x64 " ) ]
[ ValidateSet ( " NET6x64 " , " NET8x64 " ) ]
[string[]]
[string[]]
$Runtimes
$Runtimes
)
)
@ -10321,15 +10302,18 @@ function InstallDotNetRuntimes
{
{
NET6x64
NET6x64
{
{
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore ) . Version -ge [System.Version] " 1.17 " )
if ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore )
{
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller ) . Version -ge [System.Version] " 1.17 " )
# .NET Desktop Runtime 6 x64
{
winget install - -id = Microsoft . DotNet . DesktopRuntime . 6 - -architecture x64 - -exact - -force - -accept -source -agreements
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/6
# .NET Desktop Runtime 6 x64
winget install - -id = Microsoft . DotNet . DesktopRuntime . 6 - -architecture x64 - -exact - -force - -accept -source -agreements
# 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
# https://github.com/PowerShell/PowerShell/issues/21070
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
else
else
{
{
@ -10363,60 +10347,19 @@ function InstallDotNetRuntimes
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
}
NET7x64
{
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore ) . Version -ge [System.Version] " 1.17 " )
{
# https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Microsoft/DotNet/DesktopRuntime/7
# .NET Desktop Runtime 7 x64
winget install - -id = Microsoft . DotNet . DesktopRuntime . 7 - -architecture x64 - -exact - -force - -accept -source -agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
{
# .NET Desktop Runtime 7
# https://github.com/dotnet/core/blob/main/release-notes/releases-index.json
$Parameters = @ {
Uri = " https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/7.0/releases.json "
Verbose = $true
UseBasicParsing = $true
}
$LatestRelease = ( Invoke-RestMethod @Parameters ) . " latest-release "
$DownloadsFolder = Get-ItemPropertyValue -Path " HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders " -Name " {374DE290-123F-4565-9164-39C4925E467B} "
# .NET Desktop Runtime 7 x64
$Parameters = @ {
Uri = " https://dotnetcli.azureedge.net/dotnet/Runtime/ $ LatestRelease/dotnet-runtime- $ LatestRelease-win-x64.exe "
OutFile = " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe "
UseBasicParsing = $true
Verbose = $true
}
Invoke-WebRequest @Parameters
Start-Process -FilePath " $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe " -ArgumentList " /install /passive /norestart " -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @ (
" $ DownloadsFolder\dotnet-runtime- $ LatestRelease-win-x64.exe " ,
" $ env:TEMP\Microsoft_.NET_Runtime*.log "
)
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
NET8x64
NET8x64
{
{
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore ) . Version -ge [System.Version] " 1.17 " )
if ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller -ErrorAction Ignore )
{
{
# .NET Desktop Runtime 8 x64
if ( [System.Version] ( Get-AppxPackage -Name Microsoft . DesktopAppInstaller ) . Version -ge [System.Version] " 1.17 " )
winget install - -id = Microsoft . DotNet . DesktopRuntime . 8 - -architecture x64 - -exact - -force - -accept -source -agreements
{
# .NET Desktop Runtime 8 x64
winget install - -id = Microsoft . DotNet . DesktopRuntime . 8 - -architecture x64 - -exact - -force - -accept -source -agreements
# 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
# https://github.com/PowerShell/PowerShell/issues/21070
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Get-ChildItem -Path " $ env:TEMP\WinGet " -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
}
else
else
{
{
@ -11550,7 +11493,7 @@ function UninstallUWPApps
[PSCustomObject] @ {
[PSCustomObject] @ {
Name = $AppxPackage . Name
Name = $AppxPackage . Name
PackageFullName = $AppxPackage . PackageFullName
PackageFullName = $AppxPackage . PackageFullName
# Sometimes there's more than one package presented in Windows with the same package name like {Microsoft Teams, Microsoft Teams} and we need to display one the first one a window
# Sometimes there's more than one package presented in Windows with the same package name like {Microsoft Teams, Microsoft Teams} and we need to display the first one
DisplayName = $PackageId . DisplayName | Select-Object -First 1
DisplayName = $PackageId . DisplayName | Select-Object -First 1
}
}
}
}
@ -12825,10 +12768,12 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
`$ Process . Start ( ) | Out-Null
`$ Process . Start ( ) | Out-Null
" @
" @
# Create the "Windows Cleanup" task
# Create "Windows Cleanup" task
# We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
# https://github.com/PowerShell/PowerShell/issues/21377
$Action = New-ScheduledTaskAction -Execute powershell . exe -Argument " -WindowStyle Hidden -Command $ CleanupTask "
$Action = New-ScheduledTaskAction -Execute powershell . exe -Argument " -WindowStyle Hidden -Command $ CleanupTask "
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Principal = New-ScheduledTaskPrincipal -UserId " $ env:COMPUTERNAME\ $ env:USERNAME" -RunLevel Highest
$Parameters = @ {
$Parameters = @ {
TaskName = " Windows Cleanup "
TaskName = " Windows Cleanup "
TaskPath = " Sophia "
TaskPath = " Sophia "
@ -12976,9 +12921,11 @@ CreateObject("Wscript.Shell").Run "powershell.exe -ExecutionPolicy Bypass -NoPro
Set-Content -Path " $ env:SystemRoot\System32\Tasks\Sophia\Windows_Cleanup_Notification.vbs " -Value $ToastNotification -Encoding Default -Force
Set-Content -Path " $ env:SystemRoot\System32\Tasks\Sophia\Windows_Cleanup_Notification.vbs " -Value $ToastNotification -Encoding Default -Force
# Create the "Windows Cleanup Notification" task
# Create the "Windows Cleanup Notification" task
# We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
# https://github.com/PowerShell/PowerShell/issues/21377
$Action = New-ScheduledTaskAction -Execute wscript . exe -Argument " $ env:SystemRoot\System32\Tasks\Sophia\Windows_Cleanup_Notification.vbs "
$Action = New-ScheduledTaskAction -Execute wscript . exe -Argument " $ env:SystemRoot\System32\Tasks\Sophia\Windows_Cleanup_Notification.vbs "
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Principal = New-ScheduledTaskPrincipal -UserId " $ env:COMPUTERNAME\ $ env:USERNAME" -RunLevel Highest
$Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 30 -At 9pm
$Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 30 -At 9pm
$Parameters = @ {
$Parameters = @ {
TaskName = " Windows Cleanup Notification "
TaskName = " Windows Cleanup Notification "
@ -13286,9 +13233,11 @@ CreateObject("Wscript.Shell").Run "powershell.exe -ExecutionPolicy Bypass -NoPro
Set-Content -Path " $ env:SystemRoot\System32\Tasks\Sophia\SoftwareDistributionTask.vbs " -Value $SoftwareDistributionTask -Encoding Default -Force
Set-Content -Path " $ env:SystemRoot\System32\Tasks\Sophia\SoftwareDistributionTask.vbs " -Value $SoftwareDistributionTask -Encoding Default -Force
# Create the "SoftwareDistribution" task
# Create the "SoftwareDistribution" task
# We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
# https://github.com/PowerShell/PowerShell/issues/21377
$Action = New-ScheduledTaskAction -Execute wscript . exe -Argument " $ env:SystemRoot\System32\Tasks\Sophia\SoftwareDistributionTask.vbs "
$Action = New-ScheduledTaskAction -Execute wscript . exe -Argument " $ env:SystemRoot\System32\Tasks\Sophia\SoftwareDistributionTask.vbs "
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Principal = New-ScheduledTaskPrincipal -UserId " $ env:COMPUTERNAME\ $ env:USERNAME" -RunLevel Highest
$Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 90 -At 9pm
$Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 90 -At 9pm
$Parameters = @ {
$Parameters = @ {
TaskName = " SoftwareDistribution "
TaskName = " SoftwareDistribution "
@ -13603,9 +13552,11 @@ CreateObject("Wscript.Shell").Run "powershell.exe -ExecutionPolicy Bypass -NoPro
Set-Content -Path " $ env:SystemRoot\System32\Tasks\Sophia\TempTask.vbs " -Value $TempTask -Encoding Default -Force
Set-Content -Path " $ env:SystemRoot\System32\Tasks\Sophia\TempTask.vbs " -Value $TempTask -Encoding Default -Force
# Create the "Temp" task
# Create the "Temp" task
# We cannot create a schedule task if %COMPUTERNAME% is equal to %USERNAME%, so we have to use a "$env:COMPUTERNAME\$env:USERNAME" method
# https://github.com/PowerShell/PowerShell/issues/21377
$Action = New-ScheduledTaskAction -Execute wscript . exe -Argument " $ env:SystemRoot\System32\Tasks\Sophia\TempTask.vbs "
$Action = New-ScheduledTaskAction -Execute wscript . exe -Argument " $ env:SystemRoot\System32\Tasks\Sophia\TempTask.vbs "
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Principal = New-ScheduledTaskPrincipal -UserId " $ env:COMPUTERNAME\ $ env:USERNAME" -RunLevel Highest
$Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 60 -At 9pm
$Trigger = New-ScheduledTaskTrigger -Daily -DaysInterval 60 -At 9pm
$Parameters = @ {
$Parameters = @ {
TaskName = " Temp "
TaskName = " Temp "
@ -14723,66 +14674,6 @@ function EditWithPaint3DContext
}
}
}
}
<#
. SYNOPSIS
The " Edit " item in the images context menu
. PARAMETER Hide
Hide the " Edit " item from the images context menu
. PARAMETER Show
Show the " Edit " item in the images context menu
. EXAMPLE
ImagesEditContext -Hide
. EXAMPLE
ImagesEditContext -Show
. NOTES
Current user
#>
function ImagesEditContext
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
if ( -not ( ( Get-WindowsCapability -Online -Name " Microsoft.Windows.MSPaint* " ) . State -eq " Installed " ) )
{
return
}
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
if ( -not ( Test-Path -Path Registry :: HKEY_CLASSES_ROOT \ SystemFileAssociations \ image \ shell \ edit ) )
{
New-Item -Path Registry :: HKEY_CLASSES_ROOT \ SystemFileAssociations \ image \ shell \ edit -Force
}
New-ItemProperty -Path Registry :: HKEY_CLASSES_ROOT \ SystemFileAssociations \ image \ shell \ edit -Name ProgrammaticAccessOnly -PropertyType String -Value " " -Force
}
" Show "
{
Remove-ItemProperty -Path Registry :: HKEY_CLASSES_ROOT \ SystemFileAssociations \ image \ shell \ edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
}
}
}
<#
<#
. SYNOPSIS
. SYNOPSIS
The " Print " item in the . bat and . cmd context menu
The " Print " item in the . bat and . cmd context menu