@ -2,11 +2,11 @@
. SYNOPSIS
" Windows 10 Sophia Script " is a PowerShell module for Windows 10 fine-tuning and automating the routine tasks
Version : v5 . 10 . 5
Date : 17 . 05 . 2021
Version : v5 . 10 . 6
Date : 01 . 06 . 2021
Copyright ( c ) 2014 – 2021 farag
Copyright ( c ) 2019 – 2021 farag & oZ-Zo
Copyright ( c ) 2019 – 2021 farag & Inestic
Thanks to all https : / / forum . ru-board . com members involved
@ -24,22 +24,22 @@
Set execution policy to be able to run scripts only in the current PowerShell session :
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
. NOTES
https : / / forum . ru-board . com / topic . cgi ? forum = 62 & topic = 30617 #15
https : / / habr . com / post / 521202 /
https : / / forums . mydigitallife . net / threads / powershell-windows - 10 -sophia -script . 81675 /
https : / / www . reddit . com / r / PowerShell / comments / go2n5v / powershell_script_setup_windows_10 /
. LINK GitHub link
https : / / github . com / farag2 / Windows - 10 -Sophia -Script
. LINK Telegram channel & group
https : / / t . me / sophianews
https : / / t . me / sophia_chat
. LINK
. LINK Authors
https : / / github . com / farag2
https : / / github . com / Inestic
. LINK
https : / / github . com / farag2 / Windows - 10 -Sophia -Script
. NOTES
https : / / forum . ru-board . com / topic . cgi ? forum = 62 & topic = 30617 #15
https : / / habr . com / post / 521202 /
https : / / forums . mydigitallife . net / threads / powershell-windows - 10 -sophia -script . 81675 /
https : / / www . reddit . com / r / PowerShell / comments / go2n5v / powershell_script_setup_windows_10 /
#>
#region Checkings
@ -77,6 +77,13 @@ function Checkings
}
}
# Check whether the script has been run via PowerShell ISE
if ( $Host . Name -match " ISE " )
{
Write-Warning -Message $Localization . UnsupportedISE
exit
}
# Checking if the current module version is the latest one
try
{
@ -931,6 +938,10 @@ function AdvertisingID
}
" Enable "
{
if ( -not ( Test-Path -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ AdvertisingInfo ) )
{
New-Item -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ AdvertisingInfo -Force
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force
}
}
@ -1354,11 +1365,14 @@ function BingSearch
}
" Disable "
{
if ( -not ( Test-Path -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer ) )
if ( ( Get-WinHomeLocation ) . GeoId -eq 244 )
{
New-Item -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Force
if ( -not ( Test-Path -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer ) )
{
New-Item -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Force
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableSearchBoxSuggestions -PropertyType DWord -Value 1 -Force
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Policies \ Microsoft \ Windows \ Explorer -Name DisableSearchBoxSuggestions -PropertyType DWord -Value 1 -Force
}
}
}
@ -1777,167 +1791,6 @@ function OneDriveFileExplorerAd
}
}
<#
. SYNOPSIS
Configure Task View button on the taskbar
. PARAMETER Hide
Show Task View button on the taskbar
. PARAMETER Show
Do not show Task View button on the taskbar
. EXAMPLE
TaskViewButton -Hide
. EXAMPLE
TaskViewButton -Show
. NOTES
Current user
#>
function TaskViewButton
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowTaskViewButton -PropertyType DWord -Value 0 -Force
}
" Show "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowTaskViewButton -PropertyType DWord -Value 1 -Force
}
}
}
<#
. SYNOPSIS
Configure People button on the taskbar
. PARAMETER Hide
Hide People button on the taskbar
. PARAMETER Show
Show People button on the taskbar
. EXAMPLE
PeopleTaskbar -Hide
. EXAMPLE
PeopleTaskbar -Show
. NOTES
Current user
#>
function PeopleTaskbar
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
if ( -not ( Test-Path -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People ) )
{
New-Item -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Force
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Name PeopleBand -PropertyType DWord -Value 0 -Force
}
" Show "
{
if ( -not ( Test-Path -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People ) )
{
New-Item -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Force
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Name PeopleBand -PropertyType DWord -Value 1 -Force
}
}
}
<#
. SYNOPSIS
Configure seconds on the taskbar clock
. PARAMETER Hide
Hide seconds on the taskbar clock
. PARAMETER Show
Show seconds on the taskbar clock
. EXAMPLE
SecondsInSystemClock -Hide
. EXAMPLE
SecondsInSystemClock -Show
. NOTES
Current user
#>
function SecondsInSystemClock
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowSecondsInSystemClock -PropertyType DWord -Value 0 -Force
}
" Show "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowSecondsInSystemClock -PropertyType DWord -Value 1 -Force
}
}
}
<#
. SYNOPSIS
Configure windows snapping
@ -2145,30 +1998,6 @@ function RecycleBinDeleteConfirmation
$Enable
)
$UpdateDesktop = @ {
Namespace = " WinAPI "
Name = " UpdateDesktop "
Language = " CSharp "
MemberDefinition = @ "
private static readonly IntPtr hWnd = new IntPtr ( 65535 ) ;
private const int Msg = 273 ;
/ / Virtual key ID of the F5 in File Explorer
private static readonly UIntPtr UIntPtr = new UIntPtr ( 41504 ) ;
[ DllImport ( " user32.dll " , SetLastError = true ) ]
public static extern int PostMessageW ( IntPtr hWnd , uint Msg , UIntPtr wParam , IntPtr lParam ) ;
public static void PostMessage ( )
{
/ / F5 pressing simulation to refresh the desktop
PostMessageW ( hWnd , Msg , UIntPtr , IntPtr . Zero ) ;
}
" @
}
if ( -not ( " WinAPI.UpdateDesktop " -as [type] ) )
{
Add-Type @UpdateDesktop
}
$ShellState = Get-ItemPropertyValue -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer -Name ShellState
switch ( $PSCmdlet . ParameterSetName )
@ -2184,9 +2013,6 @@ public static void PostMessage()
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer -Name ShellState -PropertyType Binary -Value $ShellState -Force
}
}
# Send F5 pressing simulation to refresh the desktop
[WinAPI.UpdateDesktop] :: PostMessage ( )
}
<#
@ -2364,6 +2190,167 @@ function QuickAccessRecentFiles
}
}
<#
. SYNOPSIS
Configure Task View button on the taskbar
. PARAMETER Hide
Show Task View button on the taskbar
. PARAMETER Show
Do not show Task View button on the taskbar
. EXAMPLE
TaskViewButton -Hide
. EXAMPLE
TaskViewButton -Show
. NOTES
Current user
#>
function TaskViewButton
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowTaskViewButton -PropertyType DWord -Value 0 -Force
}
" Show "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowTaskViewButton -PropertyType DWord -Value 1 -Force
}
}
}
<#
. SYNOPSIS
Configure People button on the taskbar
. PARAMETER Hide
Hide People button on the taskbar
. PARAMETER Show
Show People button on the taskbar
. EXAMPLE
PeopleTaskbar -Hide
. EXAMPLE
PeopleTaskbar -Show
. NOTES
Current user
#>
function PeopleTaskbar
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
if ( -not ( Test-Path -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People ) )
{
New-Item -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Force
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Name PeopleBand -PropertyType DWord -Value 0 -Force
}
" Show "
{
if ( -not ( Test-Path -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People ) )
{
New-Item -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Force
}
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced \ People -Name PeopleBand -PropertyType DWord -Value 1 -Force
}
}
}
<#
. SYNOPSIS
Configure seconds on the taskbar clock
. PARAMETER Hide
Hide seconds on the taskbar clock
. PARAMETER Show
Show seconds on the taskbar clock
. EXAMPLE
SecondsInSystemClock -Hide
. EXAMPLE
SecondsInSystemClock -Show
. NOTES
Current user
#>
function SecondsInSystemClock
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show
)
switch ( $PSCmdlet . ParameterSetName )
{
" Hide "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowSecondsInSystemClock -PropertyType DWord -Value 0 -Force
}
" Show "
{
New-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced -Name ShowSecondsInSystemClock -PropertyType DWord -Value 1 -Force
}
}
}
<#
. SYNOPSIS
Configure search on the taskbar
@ -2607,17 +2594,70 @@ function MeetNow
}
}
<#
. SYNOPSIS
Configure " News and Interests "
. PARAMETER Show
Show " News and Interests "
. PARAMETER Hide
Hide " News and Interests "
. EXAMPLE
NewsInterests -Show
. EXAMPLE
NewsInterests -Hide
. NOTES
Current user
#>
function NewsInterests
{
param
(
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Show "
) ]
[switch]
$Show ,
[ Parameter (
Mandatory = $true ,
ParameterSetName = " Hide "
) ]
[switch]
$Hide
)
switch ( $PSCmdlet . ParameterSetName )
{
" Show "
{
New-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 0 -Force
}
" Hide "
{
New-ItemProperty -Path HKCU : \ Software \ Microsoft \ Windows \ CurrentVersion \ Feeds -Name ShellFeedsTaskbarViewMode -PropertyType DWord -Value 2 -Force
}
}
}
<#
. SYNOPSIS
Unpin " Microsoft Edge " and " Microsoft Store " from the taskbar
. NOTES
Current user
. LINK
https : / / github . com / Disassembler0 / Win10-Initial -Setup -Script / issues / 8 #issue-227159084
#>
function UnpinTaskbarEdgeStore
{
# Extract strings from shell32.dll using its' number
# https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/8#issue-227159084
$Signature = @ {
Namespace = " WinAPI "
Name = " GetStr "
@ -7121,6 +7161,10 @@ function Set-Association
# Generate ProgId
$ProgId = ( Get-Item -Path $ProgramPath ) . BaseName + $Extension . ToUpper ( )
}
else
{
$ProgId = $ProgramPath
}
#region functions
$RegistryUtils = @ '
@ -7285,13 +7329,15 @@ namespace RegistryUtils
)
$OpenSubKey = [Microsoft.Win32.Registry] :: CurrentUser . OpenSubKey ( $SubKey , 'ReadWriteSubTree' , 'TakeOwnership' )
$Acl = [System.Security.AccessControl.RegistrySecurity] :: new ( )
# Get current user SID
$UserSID = ( Get-CimInstance -ClassName Win32_UserAccount | Where-Object -FilterScript { $_ . Name -eq $env:USERNAME } ) . SID
$Acl . SetSecurityDescriptorSddlForm ( " O: $ UserSID ` G: $ UserSID ` D:AI(D;;DC;;; $ UserSID) " )
$OpenSubKey . SetAccessControl ( $Acl )
$OpenSubKey . Close ( )
if ( $OpenSubKey )
{
$Acl = [System.Security.AccessControl.RegistrySecurity] :: new ( )
# Get current user SID
$UserSID = ( Get-CimInstance -ClassName Win32_UserAccount | Where-Object -FilterScript { $_ . Name -eq $env:USERNAME } ) . SID
$Acl . SetSecurityDescriptorSddlForm ( " O: $ UserSID ` G: $ UserSID ` D:AI(D;;DC;;; $ UserSID) " )
$OpenSubKey . SetAccessControl ( $Acl )
$OpenSubKey . Close ( )
}
}
function Write-ExtensionKeys
@ -7314,22 +7360,21 @@ namespace RegistryUtils
)
$OrigProgID = ( Get-ItemProperty -Path " HKLM:\SOFTWARE\Classes\ $ Extension " -Name " (default) " -ErrorAction Ignore ) . " (default) "
if ( $OrigProgID )
{
# Save possible ProgIds history with extension
New-ItemProperty -Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts " -Name " $ ProgID ` _ $ Extension " -PropertyType String -Value 0 -Force
New-ItemProperty -Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts " -Name " $ ProgID ` _ $ Extension " -PropertyType DWord -Value 0 -Force
}
$Name = ( Get-Item -Path $ProgramPath ) . Name + $Extension
New-ItemProperty -Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts " -Name $Name -PropertyType String -Value 0 -Force
$Name = " {0}_ $ Extension " -f ( Split-Path -Path $ProgId -Leaf )
New-ItemProperty -Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts " -Name $Name -PropertyType DWord -Value 0 -Force
if ( " $ ProgId ` _ $ Extension " -ne $Name )
{
New-ItemProperty -Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts " -Name " $ ProgId ` _ $ Extension " -PropertyType String -Value 0 -Force
New-ItemProperty -Path " HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts " -Name " $ ProgId ` _ $ Extension " -PropertyType DWord -Value 0 -Force
}
# If ProgId doesn't exist set the specified ProgId for the exta nsions
# If ProgId doesn't exist set the specified ProgId for the exte nsions
if ( -not $OrigProgID )
{
if ( -not ( Test-Path -Path " HKCU:\SOFTWARE\Classes\ $ Extension " ) )
@ -7430,7 +7475,7 @@ namespace RegistryUtils
}
$picture = ( Get-ItemProperty -Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\KindMap " -Name $Extension -ErrorAction Ignore ) . $Extension
$PBrush = Get-ItemPropertyValue -Path " HKLM:\SOFTWARE\Classes\PBrush\CLSID " -Name " (default) "
$PBrush = ( Get-ItemProperty -Path " HKLM:\SOFTWARE\Classes\PBrush\CLSID " -Name " (default) " -ErrorAction Ignore ) . " (default) "
if ( ( $picture -eq " picture " ) -and $PBrush )
{
@ -7651,7 +7696,7 @@ namespace FileAssoc
}
New-ItemProperty -Path " HKCU:\SOFTWARE\Classes\ $ ProgId\shell\open\command " -Name " (Default) " -PropertyType String -Value " `" $ ProgramPath `" `" %1 `" " -Force
$FileNameEXE = ( Get-Item -Path $ProgramPath ) . Name
$FileNameEXE = Split-Path -Path $ProgramPath -Leaf
if ( -not ( Test-Path -Path " HKCU:\SOFTWARE\Classes\Applications\ $ FileNameEXE\shell\open\command " ) )
{
New-Item -Path " HKCU:\SOFTWARE\Classes\Applications\ $ FileNameEXE\shell\open\command " -Force
@ -7671,6 +7716,29 @@ namespace FileAssoc
# If the file extension specified configure the extension
Write-ExtensionKeys -ProgId $ProgId -Extension $Extension
# Refresh the desktop icons
$UpdateExplorer = @ {
Namespace = " WinAPI "
Name = " UpdateExplorer "
Language = " CSharp "
MemberDefinition = @ "
[ DllImport ( " shell32.dll " , CharSet = CharSet . Auto , SetLastError = false ) ]
private static extern int SHChangeNotify ( int eventId , int flags , IntPtr item1 , IntPtr item2 ) ;
public static void Refresh ( )
{
/ / Update desktop icons
SHChangeNotify ( 0x8000000 , 0x1000 , IntPtr . Zero , IntPtr . Zero ) ;
}
" @
}
if ( -not ( " WinAPI.UpdateExplorer " -as [type] ) )
{
Add-Type @UpdateExplorer
}
[WinAPI.UpdateExplorer] :: Refresh ( )
}
#endregion System
@ -8276,8 +8344,8 @@ public static string GetString(uint strId)
. NOTES
Load The WinRT . Runtime . dll and Microsoft . Windows . SDK . NET . dll assemblies to the current session in order to get localized UWP apps names
CsWinRT v1 . 2 . 5
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 16
CsWinRT v1 . 2 . 6
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 17
. LINK
https : / / github . com / microsoft / CsWinRT
@ -8731,8 +8799,8 @@ public static extern bool SetForegroundWindow(IntPtr hWnd);
. NOTES
Load The WinRT . Runtime . dll and Microsoft . Windows . SDK . NET . dll assemblies to the current session in order to get localized UWP apps names
CsWinRT v1 . 2 . 5
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 16
CsWinRT v1 . 2 . 6
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 17
. LINK
https : / / github . com / microsoft / CsWinRT
@ -11061,6 +11129,10 @@ function MSIExtractContext
. EXAMPLE
CABInstallContext -Add
. NOTES
If the . cab file extension type associated to open with a third party app by default , the " Install " context menu item won ' t be displayed ,
so the default association for the . cab file type will be restored forcedly
. NOTES
Current user
#>
@ -11087,10 +11159,17 @@ function CABInstallContext
{
" Remove "
{
Remove-Item -Path Registry :: HKEY_CLASSES_ROOT \ CABFolder \ Shell \ RunAs \ Command -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path Registry :: HKEY_CLASSES_ROOT \ CABFolder \ Shell \ RunAs -Recurse -Force -ErrorAction SilentlyContinue
}
" Add "
{
# Checking whether the File Explorer is associated with the .cab files
if ( -not ( ( Get-ItemProperty -Path HKCU : \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Explorer \ FileExts \ . cab \ UserChoice -Name ProgId -ErrorAction Ignore ) -notmatch " cab " ) )
{
# The "Install" context menu item won't be visible unless the File Explorer was assosiated with the .cab files
Set-Association -ProgramPath CABFolder -Extension . cab -Icon " %SystemRoot%\system32\cabview.dll,0 "
}
if ( -not ( Test-Path -Path Registry :: HKEY_CLASSES_ROOT \ CABFolder \ Shell \ RunAs \ Command ) )
{
New-Item -Path Registry :: HKEY_CLASSES_ROOT \ CABFolder \ Shell \ RunAs \ Command -Force
@ -12086,12 +12165,12 @@ function PreviousVersionsPage
}
#endregion Context menu
#region Refresh
function Refresh
#region Refresh Environment
function RefreshEnvironment
{
$UpdateExplorer = @ {
$UpdateEnvironment = @ {
Namespace = " WinAPI "
Name = " UpdateExplorer "
Name = " UpdateEnvironment "
Language = " CSharp "
MemberDefinition = @ "
private static readonly IntPtr HWND_BROADCAST = new IntPtr ( 0xffff ) ;
@ -12134,16 +12213,16 @@ public static void PostMessage()
}
" @
}
if ( -not ( " WinAPI.UpdateExplorer " -as [type] ) )
if ( -not ( " WinAPI.UpdateEnvironment " -as [type] ) )
{
Add-Type @UpdateExplorer
Add-Type @UpdateEnvironment
}
# Simulate pressing F5 to refresh the desktop
[WinAPI.UpdateExplorer ] :: PostMessage ( )
[WinAPI.UpdateEnvironment ] :: PostMessage ( )
# Refresh desktop icons, environment variables, taskbar
[WinAPI.UpdateExplorer ] :: Refresh ( )
[WinAPI.UpdateEnvironment ] :: Refresh ( )
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
@ -12159,8 +12238,8 @@ public static void PostMessage()
<#
. NOTES
Load The WinRT . Runtime . dll and Microsoft . Windows . SDK . NET . dll assemblies to the current session in order to get localized UWP apps names
CsWinRT v1 . 2 . 5
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 16
CsWinRT v1 . 2 . 6
Microsoft . Windows . SDK . NET 10 . 0 . 19041 . 17
. LINK
https : / / github . com / microsoft / CsWinRT
@ -12196,7 +12275,7 @@ public static void PostMessage()
$ToastMessage = [Windows.UI.Notifications.ToastNotification] :: New ( $ToastXML )
[Windows.UI.Notifications.ToastNotificationManager] :: CreateToastNotifier ( " windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel " ) . Show ( $ToastMessage )
}
#endregion Refresh
#endregion Refresh Environment
# Errors output
function Errors