Dmitry Nefedov 4 months ago
parent
commit
9ec0a7915c
  1. 2
      src/Sophia_Script_for_Windows_11/Module/Private/InitialActions.ps1
  2. 39
      src/Sophia_Script_for_Windows_11_ARM/Module/Private/Errors.ps1
  3. 1167
      src/Sophia_Script_for_Windows_11_ARM/Module/Private/InitialActions.ps1
  4. 210
      src/Sophia_Script_for_Windows_11_ARM/Module/Private/PostActions.ps1
  5. 100
      src/Sophia_Script_for_Windows_11_ARM/Module/Private/Set-Policy.ps1
  6. 95
      src/Sophia_Script_for_Windows_11_ARM/Module/Private/Show-Menu.ps1
  7. 39
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/Errors.ps1
  8. 1204
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/InitialActions.ps1
  9. 210
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/PostActions.ps1
  10. 100
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/Set-Policy.ps1
  11. 95
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/Show-Menu.ps1

2
src/Sophia_Script_for_Windows_11/Module/Private/InitialActions.ps1

@ -172,7 +172,7 @@ public static string GetIndirectString(string indirectString)
}
catch // (Exception ex)
{
return nu1ll;
return null;
// return "Exception Message: " + ex.Message;
}
}

39
src/Sophia_Script_for_Windows_11_ARM/Module/Private/Errors.ps1

@ -0,0 +1,39 @@
<#
.SYNOPSIS
Initial checks before proceeding to module execution
.VERSION
6.9.2
.DATE
19.10.2025
.COPYRIGHT
(c) 20142026 Team Sophia
.LINK
https://github.com/farag2/Sophia-Script-for-Windows
#>
function Errors
{
if ($Global:Error)
{
($Global:Error | ForEach-Object -Process {
# Some errors may have the Windows nature and don't have a path to any of the module's files
$ErrorInFile = if ($_.InvocationInfo.PSCommandPath)
{
Split-Path -Path $_.InvocationInfo.PSCommandPath -Leaf
}
[PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message
}
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()
}
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}

1167
src/Sophia_Script_for_Windows_11_ARM/Module/Private/InitialActions.ps1

File diff suppressed because it is too large

210
src/Sophia_Script_for_Windows_11_ARM/Module/Private/PostActions.ps1

@ -0,0 +1,210 @@
<#
.SYNOPSIS
Initial checks before proceeding to module execution
.VERSION
6.9.2
.DATE
19.10.2025
.COPYRIGHT
(c) 20142026 Team Sophia
.LINK
https://github.com/farag2/Sophia-Script-for-Windows
#>
function PostActions
{
#region Refresh Environment
$Signature = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
Language = "CSharp"
CompilerParameters = $CompilerParameters
MemberDefinition = @"
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
public static void Refresh()
{
// Update desktop icons
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
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()
{
// Simulate pressing F5 to refresh the desktop
PostMessageW(hWnd, Msg, UIntPtr, IntPtr.Zero);
}
"@
}
if (-not ("WinAPI.UpdateEnvironment" -as [type]))
{
Add-Type @Signature
}
# Simulate pressing F5 to refresh the desktop
[WinAPI.UpdateEnvironment]::PostMessage()
# Refresh desktop icons, environment variables, taskbar
[WinAPI.UpdateEnvironment]::Refresh()
# Restart Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled -and (-not $Script:DefenderMpPreferenceBroken))
{
if ($Script:ControlledFolderAccess)
{
Set-MpPreference -EnableControlledFolderAccess Enabled
}
}
# Kill all explorer instances in case "launch folder windows in a separate process" enabled
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders
if (Get-Variable -Name OpenedFolder -ErrorAction Ignore)
{
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath "$env:SystemRoot\explorer.exe" -ArgumentList $Script:OpenedFolder
}
}
}
# Open Startup page
Start-Process -FilePath "ms-settings:startupapps"
# Checking whether BitLocker drive encryption if off, despite drive is encrypted
if (Get-BitLockerVolume | Where-Object -FilterScript {($_.ProtectionStatus -eq "Off") -and ($_.VolumeStatus -eq "FullyEncrypted")})
{
Get-BitLockerVolume
Start-Process -FilePath "https://support.microsoft.com/windows/cf7e2b6f-3e70-4882-9532-18633605b7df"
Start-Process -FilePath "https://www.neowin.net/guides/how-to-remove-bitlocker-drive-encryption-in-windows-11/"
# Open if Windows edition is Home
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").EditionID -ne "Core")
{
# Open BitLocker settings
& "$env:SystemRoot\System32\control.exe" /name Microsoft.BitLockerDriveEncryption
}
}
# Checking whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its argument
$taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript {
$_.CommandLine -match "taskschd.msc"
}).Handle
# We have to check before executing due to "Set-StrictMode -Version Latest"
if ($taskschd_Process_ID)
{
Get-Process -Id $taskschd_Process_ID | Stop-Process -Force
}
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.ActionCenter.SmartOptOut -Name Enable -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Name ShowBanner, ShowInActionCenter, Enabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SystemSettings\AccountNotifications -Name EnableAccountNotifications -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type DELETE
Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type DELETE
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Force
}
# Register app
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Name DisplayName -Value Sophia -PropertyType String -Force
# Determines whether the app can be seen in Settings where the user can turn notifications on or off
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Name ShowInSettings -Value 0 -PropertyType DWord -Force
# Call toast notification
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
<visual>
<binding template="ToastGeneric">
<text>$($Localization.ThankfulToastTitle)</text>
<text>$($Localization.DonateToastTitle)</text>
</binding>
</visual>
<audio src="ms-winsoundevent:notification.default" />
<actions>
<action content="Ko-fi" arguments="https://ko-fi.com/farag" activationType="protocol"/>
<action content="Boosty" arguments="https://boosty.to/teamsophia" activationType="protocol"/>
</actions>
</toast>
"@
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
#endregion Toast notifications
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{
& "$PSScriptRoot\..\..\Binaries\LGPO.exe" /t "$env:TEMP\LGPO.txt"
& "$env:SystemRoot\System32\gpupdate.exe" /force
}
# 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\LGPO.txt" -Force -ErrorAction Ignore | Remove-Item -Force -ErrorAction Ignore
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://t.me/sophianews" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "https://ko-fi.com/farag" -Verbose
Write-Verbose -Message "https://boosty.to/teamsophia" -Verbose
Write-Information -MessageData "" -InformationAction Continue
}

100
src/Sophia_Script_for_Windows_11_ARM/Module/Private/Set-Policy.ps1

@ -0,0 +1,100 @@
<#
.SYNOPSIS
Create pre-configured text files for LGPO.exe tool
.EXAMPLE Set AllowTelemetry to 0 for all users in gpedit.msc snap-in
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 0
.EXAMPLE Set DisableSearchBoxSuggestions to 0 for current user in gpedit.msc snap-in
Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableSearchBoxSuggestions -Type DWORD -Value 1
.EXAMPLE Set DisableNotificationCenter value to "Not configured" in gpedit.msc snap-in
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type DELETE
.NOTES
https://techcommunity.microsoft.com/t5/microsoft-security-baselines/lgpo-exe-local-group-policy-object-utility-v1-0/ba-p/701045
.VERSION
6.9.2
.DATE
19.10.2025
.COPYRIGHT
(c) 20142026 Team Sophia
.LINK
https://github.com/farag2/Sophia-Script-for-Windows
#>
function Global:Set-Policy
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $true,
Position = 1
)]
[string]
[ValidateSet("Computer", "User")]
$Scope,
[Parameter(
Mandatory = $true,
Position = 2
)]
[string]
$Path,
[Parameter(
Mandatory = $true,
Position = 3
)]
[string]
$Name,
[Parameter(
Mandatory = $true,
Position = 4
)]
[ValidateSet("DWORD", "SZ", "EXSZ", "DELETE")]
[string]
$Type,
[Parameter(
Mandatory = $false,
Position = 5
)]
$Value
)
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
return
}
switch ($Type)
{
"DELETE"
{
$Policy = @"
$Scope
$($Path)
$($Name)
$($Type)`n
"@
}
default
{
$Policy = @"
$Scope
$($Path)
$($Name)
$($Type):$($Value)`n
"@
}
}
# Save in UTF8 without BOM
Add-Content -Path "$env:TEMP\LGPO.txt" -Value $Policy -Encoding Default -Force
}

95
src/Sophia_Script_for_Windows_11_ARM/Module/Private/Show-Menu.ps1

@ -0,0 +1,95 @@
<#
.SYNOPSIS
"Show menu" function with the up/down arrow keys and enter key to make a selection
.PARAMETER Menu
Array of items to choose from
.PARAMETER Default
Default selected item in array
.PARAMETER AddSkip
Add localized extracted "Skip" string from shell32.dll
.EXAMPLE
Show-Menu -Menu @($Item1, $Item2) -Default 1
.LINK
https://qna.habr.com/answer?answer_id=1522379
https://github.com/ryandunton/InteractivePSMenu
#>
function Global:Show-Menu
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[array]
$Menu,
[Parameter(Mandatory = $true)]
[int]
$Default,
[Parameter(Mandatory = $false)]
[switch]
$AddSkip
)
Write-Information -MessageData "" -InformationAction Continue
# Add "Please use the arrow keys 🠕 and 🠗 on your keyboard to select your answer" to menu
$Menu += $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
if ($AddSkip)
{
# Extract the localized "Skip" string from shell32.dll
$Menu += [WinAPI.GetStrings]::GetString(16956)
}
$i = 0
while ($i -lt $Menu.Count)
{
$i++
Write-Host -Object ""
}
$SelectedValueIndex = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
do
{
[Console]::SetCursorPosition(0, [Console]::CursorTop - $Menu.Count)
for ($i = 0; $i -lt $Menu.Count; $i++)
{
if ($i -eq $SelectedValueIndex)
{
Write-Host -Object "[>] $($Menu[$i])" -NoNewline
}
else
{
Write-Host -Object "[ ] $($Menu[$i])" -NoNewline
}
Write-Host -Object ""
}
$Key = [Console]::ReadKey()
switch ($Key.Key)
{
"UpArrow"
{
$SelectedValueIndex = [Math]::Max(0, $SelectedValueIndex - 1)
}
"DownArrow"
{
$SelectedValueIndex = [Math]::Min($Menu.Count - 1, $SelectedValueIndex + 1)
}
"Enter"
{
return $Menu[$SelectedValueIndex]
}
}
}
while ($Key.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter))
}

39
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/Errors.ps1

@ -0,0 +1,39 @@
<#
.SYNOPSIS
Initial checks before proceeding to module execution
.VERSION
6.9.2
.DATE
19.10.2025
.COPYRIGHT
(c) 20142026 Team Sophia
.LINK
https://github.com/farag2/Sophia-Script-for-Windows
#>
function Errors
{
if ($Global:Error)
{
($Global:Error | ForEach-Object -Process {
# Some errors may have the Windows nature and don't have a path to any of the module's files
$ErrorInFile = if ($_.InvocationInfo.PSCommandPath)
{
Split-Path -Path $_.InvocationInfo.PSCommandPath -Leaf
}
[PSCustomObject]@{
$Localization.ErrorsLine = $_.InvocationInfo.ScriptLineNumber
# Extract the localized "File" string from shell32.dll
"$([WinAPI.GetStrings]::GetString(4130))" = $ErrorInFile
$Localization.ErrorsMessage = $_.Exception.Message
}
} | Sort-Object -Property $Localization.ErrorsLine | Format-Table -AutoSize -Wrap | Out-String).Trim()
}
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}

1204
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/InitialActions.ps1

File diff suppressed because it is too large

210
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/PostActions.ps1

@ -0,0 +1,210 @@
<#
.SYNOPSIS
Initial checks before proceeding to module execution
.VERSION
6.9.2
.DATE
19.10.2025
.COPYRIGHT
(c) 20142026 Team Sophia
.LINK
https://github.com/farag2/Sophia-Script-for-Windows
#>
function PostActions
{
#region Refresh Environment
$Signature = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
Language = "CSharp"
CompilerOptions = $CompilerOptions
MemberDefinition = @"
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
private const int WM_SETTINGCHANGE = 0x1a;
private const int SMTO_ABORTIFHUNG = 0x0002;
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
public static void Refresh()
{
// Update desktop icons
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Update environment variables
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
// Update taskbar
SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
}
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()
{
// Simulate pressing F5 to refresh the desktop
PostMessageW(hWnd, Msg, UIntPtr, IntPtr.Zero);
}
"@
}
if (-not ("WinAPI.UpdateEnvironment" -as [type]))
{
Add-Type @Signature
}
# Simulate pressing F5 to refresh the desktop
[WinAPI.UpdateEnvironment]::PostMessage()
# Refresh desktop icons, environment variables, taskbar
[WinAPI.UpdateEnvironment]::Refresh()
# Restart Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled -and (-not $Script:DefenderMpPreferenceBroken))
{
if ($Script:ControlledFolderAccess)
{
Set-MpPreference -EnableControlledFolderAccess Enabled
}
}
# Kill all explorer instances in case "launch folder windows in a separate process" enabled
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders
if (Get-Variable -Name OpenedFolder -ErrorAction Ignore)
{
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath "$env:SystemRoot\explorer.exe" -ArgumentList $Script:OpenedFolder
}
}
}
# Open Startup page
Start-Process -FilePath "ms-settings:startupapps"
# Checking whether BitLocker drive encryption if off, despite drive is encrypted
if (Get-BitLockerVolume | Where-Object -FilterScript {($_.ProtectionStatus -eq "Off") -and ($_.VolumeStatus -eq "FullyEncrypted")})
{
Get-BitLockerVolume
Start-Process -FilePath "https://support.microsoft.com/windows/cf7e2b6f-3e70-4882-9532-18633605b7df"
Start-Process -FilePath "https://www.neowin.net/guides/how-to-remove-bitlocker-drive-encryption-in-windows-11/"
# Open if Windows edition is Home
if ((Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").EditionID -ne "Core")
{
# Open BitLocker settings
& "$env:SystemRoot\System32\control.exe" /name Microsoft.BitLockerDriveEncryption
}
}
# Checking whether any of scheduled tasks were created. Unless open Task Scheduler
if ($Script:ScheduledTasks)
{
# Find and close taskschd.msc by its argument
$taskschd_Process_ID = (Get-CimInstance -ClassName CIM_Process | Where-Object -FilterScript {$_.Name -eq "mmc.exe"} | Where-Object -FilterScript {
$_.CommandLine -match "taskschd.msc"
}).Handle
# We have to check before executing due to "Set-StrictMode -Version Latest"
if ($taskschd_Process_ID)
{
Get-Process -Id $taskschd_Process_ID | Stop-Process -Force
}
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Enable notifications
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications -Name ToastEnabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.ActionCenter.SmartOptOut -Name Enable -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia -Name ShowBanner, ShowInActionCenter, Enabled -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\SystemSettings\AccountNotifications -Name EnableAccountNotifications -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\Explorer, HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Force -ErrorAction Ignore
Remove-ItemProperty -Path HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications -Name NoToastApplicationNotification -Force -ErrorAction Ignore
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type DELETE
Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type DELETE
if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia))
{
New-Item -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Force
}
# Register app
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Name DisplayName -Value Sophia -PropertyType String -Force
# Determines whether the app can be seen in Settings where the user can turn notifications on or off
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Name ShowInSettings -Value 0 -PropertyType DWord -Force
# Call toast notification
Add-Type -AssemblyName "$PSScriptRoot\..\..\Binaries\WinRT.Runtime.dll"
Add-Type -AssemblyName "$PSScriptRoot\..\..\Binaries\Microsoft.Windows.SDK.NET.dll"
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
<visual>
<binding template="ToastGeneric">
<text>$($Localization.ThankfulToastTitle)</text>
<text>$($Localization.DonateToastTitle)</text>
</binding>
</visual>
<audio src="ms-winsoundevent:notification.default" />
<actions>
<action content="Ko-fi" arguments="https://ko-fi.com/farag" activationType="protocol"/>
<action content="Boosty" arguments="https://boosty.to/teamsophia" activationType="protocol"/>
</actions>
</toast>
"@
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
#endregion Toast notifications
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{
& "$PSScriptRoot\..\..\Binaries\LGPO.exe" /t "$env:TEMP\LGPO.txt"
& "$env:SystemRoot\System32\gpupdate.exe" /force
}
# 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\LGPO.txt" -Force -ErrorAction Ignore | Remove-Item -Force -ErrorAction Ignore
Write-Verbose -Message "https://t.me/sophia_chat" -Verbose
Write-Verbose -Message "https://t.me/sophianews" -Verbose
Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message "https://ko-fi.com/farag" -Verbose
Write-Verbose -Message "https://boosty.to/teamsophia" -Verbose
Write-Information -MessageData "" -InformationAction Continue
}

100
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/Set-Policy.ps1

@ -0,0 +1,100 @@
<#
.SYNOPSIS
Create pre-configured text files for LGPO.exe tool
.EXAMPLE Set AllowTelemetry to 0 for all users in gpedit.msc snap-in
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWORD -Value 0
.EXAMPLE Set DisableSearchBoxSuggestions to 0 for current user in gpedit.msc snap-in
Set-Policy -Scope User -Path Software\Policies\Microsoft\Windows\Explorer -Name DisableSearchBoxSuggestions -Type DWORD -Value 1
.EXAMPLE Set DisableNotificationCenter value to "Not configured" in gpedit.msc snap-in
Set-Policy -Scope Computer -Path SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableNotificationCenter -Type DELETE
.NOTES
https://techcommunity.microsoft.com/t5/microsoft-security-baselines/lgpo-exe-local-group-policy-object-utility-v1-0/ba-p/701045
.VERSION
6.9.2
.DATE
19.10.2025
.COPYRIGHT
(c) 20142026 Team Sophia
.LINK
https://github.com/farag2/Sophia-Script-for-Windows
#>
function Global:Set-Policy
{
[CmdletBinding()]
param
(
[Parameter(
Mandatory = $true,
Position = 1
)]
[string]
[ValidateSet("Computer", "User")]
$Scope,
[Parameter(
Mandatory = $true,
Position = 2
)]
[string]
$Path,
[Parameter(
Mandatory = $true,
Position = 3
)]
[string]
$Name,
[Parameter(
Mandatory = $true,
Position = 4
)]
[ValidateSet("DWORD", "SZ", "EXSZ", "DELETE")]
[string]
$Type,
[Parameter(
Mandatory = $false,
Position = 5
)]
$Value
)
if (-not (Test-Path -Path "$env:SystemRoot\System32\gpedit.msc"))
{
return
}
switch ($Type)
{
"DELETE"
{
$Policy = @"
$Scope
$($Path)
$($Name)
$($Type)`n
"@
}
default
{
$Policy = @"
$Scope
$($Path)
$($Name)
$($Type):$($Value)`n
"@
}
}
# Save in UTF8 without BOM
Add-Content -Path "$env:TEMP\LGPO.txt" -Value $Policy -Encoding Default -Force
}

95
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/Show-Menu.ps1

@ -0,0 +1,95 @@
<#
.SYNOPSIS
"Show menu" function with the up/down arrow keys and enter key to make a selection
.PARAMETER Menu
Array of items to choose from
.PARAMETER Default
Default selected item in array
.PARAMETER AddSkip
Add localized extracted "Skip" string from shell32.dll
.EXAMPLE
Show-Menu -Menu @($Item1, $Item2) -Default 1
.LINK
https://qna.habr.com/answer?answer_id=1522379
https://github.com/ryandunton/InteractivePSMenu
#>
function Global:Show-Menu
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[array]
$Menu,
[Parameter(Mandatory = $true)]
[int]
$Default,
[Parameter(Mandatory = $false)]
[switch]
$AddSkip
)
Write-Information -MessageData "" -InformationAction Continue
# Add "Please use the arrow keys 🠕 and 🠗 on your keyboard to select your answer" to menu
$Menu += $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x2191), [System.Char]::ConvertFromUtf32(0x2193)
if ($AddSkip)
{
# Extract the localized "Skip" string from shell32.dll
$Menu += [WinAPI.GetStrings]::GetString(16956)
}
$i = 0
while ($i -lt $Menu.Count)
{
$i++
Write-Host -Object ""
}
$SelectedValueIndex = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
do
{
[Console]::SetCursorPosition(0, [Console]::CursorTop - $Menu.Count)
for ($i = 0; $i -lt $Menu.Count; $i++)
{
if ($i -eq $SelectedValueIndex)
{
Write-Host -Object "[>] $($Menu[$i])" -NoNewline
}
else
{
Write-Host -Object "[ ] $($Menu[$i])" -NoNewline
}
Write-Host -Object ""
}
$Key = [Console]::ReadKey()
switch ($Key.Key)
{
"UpArrow"
{
$SelectedValueIndex = [Math]::Max(0, $SelectedValueIndex - 1)
}
"DownArrow"
{
$SelectedValueIndex = [Math]::Min($Menu.Count - 1, $SelectedValueIndex + 1)
}
"Enter"
{
return $Menu[$SelectedValueIndex]
}
}
}
while ($Key.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter))
}
Loading…
Cancel
Save