Browse Source

Improved Scheduled tasks

master
Dmitry Nefedov 3 months ago
parent
commit
24013e9d91
  1. 84
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 71
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 84
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 84
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 88
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 84
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

84
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -10557,9 +10557,9 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
$Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
$Distributions = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Distribution" = $_.FriendlyName
"Alias" = $_.Name
}
}
@ -10643,16 +10643,16 @@ function Install-WSL
}
#endregion
foreach ($Distro in $Distros)
foreach ($Distribution in $Distributions)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.GroupName = "WslDistribution"
$RadioButton.Tag = $Distribution.Alias
$RadioButton.Add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$TextBlock.Text = $Distribution.Distribution
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
@ -10697,7 +10697,6 @@ function Install-WSL
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
#endregion WSL
@ -12125,31 +12124,14 @@ function CleanupTask
{
"Register"
{
# Checking if notifications and Action Center are disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
$MachineNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
if (($UserNotificationCenter -eq 1) -or ($MachineNotificationCenter -eq 1))
{
Write-Verbose -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
@ -12576,18 +12558,14 @@ function SoftwareDistributionTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
@ -12887,18 +12865,14 @@ function TempTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
@ -14916,6 +14890,12 @@ public static void PostMessage()
#region Toast notifications
# Persist Sophia notifications to prevent to immediately disappear from Action Center
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Force

71
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -8976,31 +8976,14 @@ function CleanupTask
{
"Register"
{
# Checking if notifications and Action Center are disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
$MachineNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
if (($UserNotificationCenter -eq 1) -or ($MachineNotificationCenter -eq 1))
{
Write-Verbose -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
@ -9427,18 +9410,14 @@ function SoftwareDistributionTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
@ -9738,18 +9717,14 @@ function TempTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
@ -11690,6 +11665,12 @@ public static void PostMessage()
#region Toast notifications
# Persist Sophia notifications to prevent to immediately disappear from Action Center
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Force

84
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -9433,9 +9433,9 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
$Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
$Distributions = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Distribution" = $_.FriendlyName
"Alias" = $_.Name
}
}
@ -9519,16 +9519,16 @@ function Install-WSL
}
#endregion
foreach ($Distro in $Distros)
foreach ($Distribution in $Distributions)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.GroupName = "WslDistribution"
$RadioButton.Tag = $Distribution.Alias
$RadioButton.Add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$TextBlock.Text = $Distribution.Distribution
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
@ -9573,7 +9573,6 @@ function Install-WSL
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
#endregion WSL
@ -10111,31 +10110,14 @@ function CleanupTask
{
"Register"
{
# Checking if notifications and Action Center are disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
$MachineNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
if (($UserNotificationCenter -eq 1) -or ($MachineNotificationCenter -eq 1))
{
Write-Verbose -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
@ -10562,18 +10544,14 @@ function SoftwareDistributionTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
@ -10873,18 +10851,14 @@ function TempTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
@ -12885,6 +12859,12 @@ public static void PostMessage()
#region Toast notifications
# Persist Sophia notifications to prevent to immediately disappear from Action Center
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Force

84
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -10563,9 +10563,9 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
$Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
$Distributions = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Distribution" = $_.FriendlyName
"Alias" = $_.Name
}
}
@ -10649,16 +10649,16 @@ function Install-WSL
}
#endregion
foreach ($Distro in $Distros)
foreach ($Distribution in $Distributions)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.GroupName = "WslDistribution"
$RadioButton.Tag = $Distribution.Alias
$RadioButton.Add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$TextBlock.Text = $Distribution.Distribution
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
@ -10703,7 +10703,6 @@ function Install-WSL
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
#endregion WSL
@ -12141,31 +12140,14 @@ function CleanupTask
{
"Register"
{
# Checking if notifications and Action Center are disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
$MachineNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
if (($UserNotificationCenter -eq 1) -or ($MachineNotificationCenter -eq 1))
{
Write-Verbose -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
@ -12592,18 +12574,14 @@ function SoftwareDistributionTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
@ -12903,18 +12881,14 @@ function TempTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
@ -14932,6 +14906,12 @@ public static void PostMessage()
#region Toast notifications
# Persist Sophia notifications to prevent to immediately disappear from Action Center
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Force

88
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -7845,7 +7845,7 @@ function WinPrtScrFolder
.NOTES
Machine-wide
#>
function RecommendedTroubleshooting ###
function RecommendedTroubleshooting
{
param
(
@ -10183,9 +10183,9 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
$Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
$Distributions = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Distribution" = $_.FriendlyName
"Alias" = $_.Name
}
}
@ -10269,16 +10269,16 @@ function Install-WSL
}
#endregion
foreach ($Distro in $Distros)
foreach ($Distribution in $Distributions)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.GroupName = "WslDistribution"
$RadioButton.Tag = $Distribution.Alias
$RadioButton.Add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$TextBlock.Text = $Distribution.Distribution
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
@ -10323,7 +10323,6 @@ function Install-WSL
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
#endregion WSL
@ -11300,31 +11299,14 @@ function CleanupTask
{
"Register"
{
# Checking if notifications and Action Center are disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
$MachineNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
if (($UserNotificationCenter -eq 1) -or ($MachineNotificationCenter -eq 1))
{
Write-Verbose -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
@ -11751,18 +11733,14 @@ function SoftwareDistributionTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
@ -12062,18 +12040,14 @@ function TempTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
@ -12862,7 +12836,7 @@ function SaveZoneInformation
.NOTES
Current user
#>
function WindowsScriptHost
function WindowsScriptHost ###
{
param
(
@ -14092,6 +14066,12 @@ public static void PostMessage()
#region Toast notifications
# Persist Sophia notifications to prevent to immediately disappear from Action Center
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Force

84
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -10187,9 +10187,9 @@ function Install-WSL
UseBasicParsing = $true
Verbose = $true
}
$Distros = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
$Distributions = (Invoke-RestMethod @Parameters).Distributions | ForEach-Object -Process {
[PSCustomObject]@{
"Distro" = $_.FriendlyName
"Distribution" = $_.FriendlyName
"Alias" = $_.Name
}
}
@ -10273,16 +10273,16 @@ function Install-WSL
}
#endregion
foreach ($Distro in $Distros)
foreach ($Distribution in $Distributions)
{
$Panel = New-Object -TypeName System.Windows.Controls.StackPanel
$RadioButton = New-Object -TypeName System.Windows.Controls.RadioButton
$TextBlock = New-Object -TypeName System.Windows.Controls.TextBlock
$Panel.Orientation = "Horizontal"
$RadioButton.GroupName = "WslDistro"
$RadioButton.Tag = $Distro.Alias
$RadioButton.GroupName = "WslDistribution"
$RadioButton.Tag = $Distribution.Alias
$RadioButton.Add_Checked({RadioButtonChecked})
$TextBlock.Text = $Distro.Distro
$TextBlock.Text = $Distribution.Distribution
$Panel.Children.Add($RadioButton) | Out-Null
$Panel.Children.Add($TextBlock) | Out-Null
$PanelContainer.Children.Add($Panel) | Out-Null
@ -10327,7 +10327,6 @@ function Install-WSL
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
#endregion WSL
@ -11314,31 +11313,14 @@ function CleanupTask
{
"Register"
{
# Checking if notifications and Action Center are disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
$MachineNotificationCenter = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Explorer", "DisableNotificationCenter", $null)
if (($UserNotificationCenter -eq 1) -or ($MachineNotificationCenter -eq 1))
{
Write-Verbose -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.ActionCenter -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
return
}
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName "Windows Cleanup" -ErrorAction Ignore)
@ -11765,18 +11747,14 @@ function SoftwareDistributionTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
@ -12076,18 +12054,14 @@ function TempTask
{
"Register"
{
# Checking if Windows Script Host is disabled
# Due to "Set-StrictMode -Version Latest" we have to use GetValue()
$UserScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
$MachineScriptHost = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings", "Enabled", $null)
if (($UserScriptHost -eq 0) -or ($MachineScriptHost -eq 0))
{
Write-Verbose -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -Verbose
Write-Error -Message ($Localization.WindowsScriptHost -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
return
}
# Remove registry keys if Windows Script Host is disabled
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows Script Host\Settings", "HKLM:\Software\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
@ -14106,6 +14080,12 @@ public static void PostMessage()
#region Toast notifications
# Persist Sophia notifications to prevent to immediately disappear from Action Center
# Remove registry keys if notifications and Action Center are disabled
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Force

Loading…
Cancel
Save