Browse Source

Improved checks

pull/469/head
Dmitry Nefedov 1 year ago
parent
commit
8dafcf2d3c
  1. 77
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 60
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 62
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 77
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 73
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 73
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

77
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -176,6 +176,8 @@ function Checks
"Defender Control" = "$env:APPDATA\Defender Control"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=260#12
"Defender Switch" = "$env:ProgramData\DSW"
# https://revi.cc/revios/download
"Revision Tool" = "${env:ProgramFiles(x86)}\Revision Tool"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@ -198,6 +200,15 @@ function Checks
}
}
# Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
@ -569,7 +580,8 @@ public static string GetString(uint strId)
# Enable back the SysMain service if it was disabled by harmful tweakers
if ((Get-Service -Name SysMain).Status -eq "Stopped")
{
Get-Service -Name SysMain | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name SysMain | Set-Service -StartupType Automatic
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
@ -759,13 +771,54 @@ function DiagTrackService
$Enable
)
# Revert back removed or commented out "Checks" functions
# Get the name of a preset (e.g Sophia.ps1) regardless it was named
$PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File -match ".ps1"}).File
if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch)
{
# The string exists and is commented
if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true)
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to uncomment "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber
# Get date from the required line to replace it with "Checks -Warning"
$RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -match $LineNumber}
(Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
else
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to add after "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber
# Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file
$UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)])
Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
# Connected User Experiences and Telemetry
# Disabling the "Connected User Experiences and Telemetry" service (DiagTrack) can cause you not being able to get Xbox achievements anymore and affects Feedback Hub
Get-Service -Name DiagTrack | Stop-Service -Force | Set-Service -StartupType Disabled
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Block connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
@ -773,7 +826,8 @@ function DiagTrackService
"Enable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
# Allow connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
@ -3257,6 +3311,9 @@ function UnpinTaskbarShortcuts
$Shortcuts
)
# Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387)
foreach ($Shortcut in $Shortcuts)
{
switch ($Shortcut)
@ -3269,7 +3326,7 @@ function UnpinTaskbarShortcuts
$Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq "$([WinAPI.GetStr]::GetString(5387))"} | ForEach-Object -Process {$_.DoIt()}
}
}
Store
@ -3279,8 +3336,7 @@ function UnpinTaskbarShortcuts
{
Start-Job -ScriptBlock {
$Apps = (New-Object -ComObject Shell.Application).NameSpace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}").Items()
# Extract the localized "Unpin from taskbar" string from shell32.dll
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq $using:LocalizedString} | ForEach-Object -Process {$_.DoIt()}
} | Receive-Job -Wait -AutoRemoveJob
}
}
@ -3291,8 +3347,7 @@ function UnpinTaskbarShortcuts
{
Start-Job -ScriptBlock {
$Apps = (New-Object -ComObject Shell.Application).NameSpace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}").Items()
# Extract the localized "Unpin from taskbar" string from shell32.dll
($Apps | Where-Object -FilterScript {$_.Path -eq "microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail"}).Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
($Apps | Where-Object -FilterScript {$_.Path -eq "microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail"}).Verbs() | Where-Object -FilterScript {$_.Name -eq $using:LocalizedString} | ForEach-Object -Process {$_.DoIt()}
} | Receive-Job -Wait -AutoRemoveJob
}
}
@ -7815,10 +7870,10 @@ function WinPrtScrFolder
if ($PresetName)
{
# Check whether a preset contains the "OneDrive -Uninstall" string uncommented out
if (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall")
if (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch)
{
# The string exists and is commented
$IsOneDriveToUninstall = (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall").Line.StartsWith("#") -eq $false
$IsOneDriveToUninstall = (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch).Line.StartsWith("#") -eq $false
}
else
{
@ -9859,7 +9914,7 @@ function Install-WSL
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
# Calculate the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {

60
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -170,6 +170,8 @@ function Checks
"Defender Control" = "$env:APPDATA\Defender Control"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=260#12
"Defender Switch" = "$env:ProgramData\DSW"
# https://revi.cc/revios/download
"Revision Tool" = "${env:ProgramFiles(x86)}\Revision Tool"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@ -192,6 +194,15 @@ function Checks
}
}
# Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
@ -529,7 +540,8 @@ public static string GetString(uint strId)
# Enable back the SysMain service if it was disabled by harmful tweakers
if ((Get-Service -Name SysMain).Status -eq "Stopped")
{
Get-Service -Name SysMain | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name SysMain | Set-Service -StartupType Automatic
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
@ -716,12 +728,53 @@ function DiagTrackService
$Enable
)
# Revert back removed or commented out "Checks" functions
# Get the name of a preset (e.g Sophia.ps1) regardless it was named
$PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File -match ".ps1"}).File
if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch)
{
# The string exists and is commented
if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true)
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to uncomment "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber
# Get date from the required line to replace it with "Checks -Warning"
$RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -match $LineNumber}
(Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
else
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to add after "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber
# Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file
$UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)])
Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Stop-Service -Force | Set-Service -StartupType Disabled
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Block connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
@ -729,7 +782,8 @@ function DiagTrackService
"Enable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
# Allow connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow

62
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -170,6 +170,8 @@ function Checks
"Defender Control" = "$env:APPDATA\Defender Control"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=260#12
"Defender Switch" = "$env:ProgramData\DSW"
# https://revi.cc/revios/download
"Revision Tool" = "${env:ProgramFiles(x86)}\Revision Tool"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@ -192,6 +194,15 @@ function Checks
}
}
# Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
@ -529,7 +540,8 @@ public static string GetString(uint strId)
# Enable back the SysMain service if it was disabled by harmful tweakers
if ((Get-Service -Name SysMain).Status -eq "Stopped")
{
Get-Service -Name SysMain | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name SysMain | Set-Service -StartupType Automatic
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
@ -716,12 +728,53 @@ function DiagTrackService
$Enable
)
# Revert back removed or commented out "Checks" functions
# Get the name of a preset (e.g Sophia.ps1) regardless it was named
$PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File -match ".ps1"}).File
if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch)
{
# The string exists and is commented
if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true)
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to uncomment "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber
# Get date from the required line to replace it with "Checks -Warning"
$RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -match $LineNumber}
(Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
else
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to add after "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber
# Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file
$UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)])
Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Stop-Service -Force | Set-Service -StartupType Disabled
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Block connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
@ -729,7 +782,8 @@ function DiagTrackService
"Enable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
# Allow connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
@ -8829,7 +8883,7 @@ function Install-WSL
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
# Calculate the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {

77
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -176,6 +176,8 @@ function Checks
"Defender Control" = "$env:APPDATA\Defender Control"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=260#12
"Defender Switch" = "$env:ProgramData\DSW"
# https://revi.cc/revios/download
"Revision Tool" = "${env:ProgramFiles(x86)}\Revision Tool"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@ -198,6 +200,15 @@ function Checks
}
}
# Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Check whether LGPO.exe exists in the bin folder
# Check whether all necessary files exist in the bin folder
$Files = @(
@ -575,7 +586,8 @@ public static string GetString(uint strId)
# Enable back the SysMain service if it was disabled by harmful tweakers
if ((Get-Service -Name SysMain).Status -eq "Stopped")
{
Get-Service -Name SysMain | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name SysMain | Set-Service -StartupType Automatic
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
@ -768,13 +780,54 @@ function DiagTrackService
$Enable
)
# Revert back removed or commented out "Checks" functions
# Get the name of a preset (e.g Sophia.ps1) regardless it was named
$PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File -match ".ps1"}).File
if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch)
{
# The string exists and is commented
if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true)
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to uncomment "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber
# Get date from the required line to replace it with "Checks -Warning"
$RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -match $LineNumber}
(Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
else
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to add after "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber
# Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file
$UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)])
Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
# Connected User Experiences and Telemetry
# Disabling the "Connected User Experiences and Telemetry" service (DiagTrack) can cause you not being able to get Xbox achievements anymore and affects Feedback Hub
Get-Service -Name DiagTrack | Stop-Service -Force | Set-Service -StartupType Disabled
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Block connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
@ -782,7 +835,8 @@ function DiagTrackService
"Enable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
# Allow connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
@ -3266,6 +3320,9 @@ function UnpinTaskbarShortcuts
$Shortcuts
)
# Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387)
foreach ($Shortcut in $Shortcuts)
{
switch ($Shortcut)
@ -3278,7 +3335,7 @@ function UnpinTaskbarShortcuts
$Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq "$([WinAPI.GetStr]::GetString(5387))"} | ForEach-Object -Process {$_.DoIt()}
}
}
Store
@ -3288,8 +3345,7 @@ function UnpinTaskbarShortcuts
{
Start-Job -ScriptBlock {
$Apps = (New-Object -ComObject Shell.Application).NameSpace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}").Items()
# Extract the localized "Unpin from taskbar" string from shell32.dll
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq $using:LocalizedString} | ForEach-Object -Process {$_.DoIt()}
} | Receive-Job -Wait -AutoRemoveJob
}
}
@ -3300,8 +3356,7 @@ function UnpinTaskbarShortcuts
{
Start-Job -ScriptBlock {
$Apps = (New-Object -ComObject Shell.Application).NameSpace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}").Items()
# Extract the localized "Unpin from taskbar" string from shell32.dll
($Apps | Where-Object -FilterScript {$_.Path -eq "microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail"}).Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
($Apps | Where-Object -FilterScript {$_.Path -eq "microsoft.windowscommunicationsapps_8wekyb3d8bbwe!microsoft.windowslive.mail"}).Verbs() | Where-Object -FilterScript {$_.Name -eq $using:LocalizedString} | ForEach-Object -Process {$_.DoIt()}
} | Receive-Job -Wait -AutoRemoveJob
}
}
@ -7825,10 +7880,10 @@ function WinPrtScrFolder
if ($PresetName)
{
# Check whether a preset contains the "OneDrive -Uninstall" string uncommented out
if (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall")
if (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch)
{
# The string exists and is commented
$IsOneDriveToUninstall = (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall").Line.StartsWith("#") -eq $false
$IsOneDriveToUninstall = (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch).Line.StartsWith("#") -eq $false
}
else
{
@ -9869,7 +9924,7 @@ function Install-WSL
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
# Calculate the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {

73
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -266,6 +266,8 @@ function Checks
"Defender Control" = "$env:APPDATA\Defender Control"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=260#12
"Defender Switch" = "$env:ProgramData\DSW"
# https://revi.cc/revios/download
"Revision Tool" = "${env:ProgramFiles(x86)}\Revision Tool"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@ -288,6 +290,15 @@ function Checks
}
}
# Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Check whether LGPO.exe exists in the bin folder
if (-not (Test-Path -Path "$PSScriptRoot\..\bin\LGPO.exe"))
{
@ -623,7 +634,8 @@ public static string GetString(uint strId)
# Enable back the SysMain service if it was disabled by harmful tweakers
if ((Get-Service -Name SysMain).Status -eq "Stopped")
{
Get-Service -Name SysMain | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name SysMain | Set-Service -StartupType Automatic
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
@ -813,13 +825,54 @@ function DiagTrackService
$Enable
)
# Revert back removed or commented out "Checks" functions
# Get the name of a preset (e.g Sophia.ps1) regardless it was named
$PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File -match ".ps1"}).File
if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch)
{
# The string exists and is commented
if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true)
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to uncomment "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber
# Get date from the required line to replace it with "Checks -Warning"
$RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -match $LineNumber}
(Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
else
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to add after "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber
# Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file
$UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)])
Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
# Connected User Experiences and Telemetry
# Disabling the "Connected User Experiences and Telemetry" service (DiagTrack) can cause you not being able to get Xbox achievements anymore and affects Feedback Hub
Get-Service -Name DiagTrack | Stop-Service -Force | Set-Service -StartupType Disabled
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Block connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
@ -827,7 +880,8 @@ function DiagTrackService
"Enable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
# Allow connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
@ -2916,6 +2970,9 @@ function UnpinTaskbarShortcuts
$Shortcuts
)
# Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387)
foreach ($Shortcut in $Shortcuts)
{
switch ($Shortcut)
@ -2928,7 +2985,7 @@ function UnpinTaskbarShortcuts
$Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq "$([WinAPI.GetStr]::GetString(5387))"} | ForEach-Object -Process {$_.DoIt()}
}
}
Store
@ -2939,7 +2996,7 @@ function UnpinTaskbarShortcuts
Start-Job -ScriptBlock {
$Apps = (New-Object -ComObject Shell.Application).NameSpace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}").Items()
# Extract the localized "Unpin from taskbar" string from shell32.dll
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq $using:LocalizedString} | ForEach-Object -Process {$_.DoIt()}
} | Receive-Job -Wait -AutoRemoveJob
}
}
@ -7330,10 +7387,10 @@ function WinPrtScrFolder
if ($PresetName)
{
# Check whether a preset contains the "OneDrive -Uninstall" string uncommented out
if (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall")
if (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch)
{
# The string exists and is commented
$IsOneDriveToUninstall = (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall").Line.StartsWith("#") -eq $false
$IsOneDriveToUninstall = (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch).Line.StartsWith("#") -eq $false
}
else
{
@ -9482,7 +9539,7 @@ function Install-WSL
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
# Calculate the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {

73
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -266,6 +266,8 @@ function Checks
"Defender Control" = "$env:APPDATA\Defender Control"
# https://forum.ru-board.com/topic.cgi?forum=5&topic=14285&start=260#12
"Defender Switch" = "$env:ProgramData\DSW"
# https://revi.cc/revios/download
"Revision Tool" = "${env:ProgramFiles(x86)}\Revision Tool"
}
foreach ($Tweaker in $Tweakers.Keys)
{
@ -288,6 +290,15 @@ function Checks
}
}
# Flibustier custom Windows image
if (Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\.NETFramework\Performance -Name *flibustier)
{
Write-Warning -Message ($Localization.TweakerWarning -f "flblauncher")
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
# Check whether all necessary files exist in the bin folder
$Files = @(
"$PSScriptRoot\..\bin\LGPO.exe",
@ -628,7 +639,8 @@ public static string GetString(uint strId)
# Enable back the SysMain service if it was disabled by harmful tweakers
if ((Get-Service -Name SysMain).Status -eq "Stopped")
{
Get-Service -Name SysMain | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name SysMain | Set-Service -StartupType Automatic
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
@ -820,13 +832,54 @@ function DiagTrackService
$Enable
)
# Revert back removed or commented out "Checks" functions
# Get the name of a preset (e.g Sophia.ps1) regardless it was named
$PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File -match ".ps1"}).File
if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch)
{
# The string exists and is commented
if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true)
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to uncomment "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber
# Get date from the required line to replace it with "Checks -Warning"
$RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -match $LineNumber}
(Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
}
else
{
$Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)"
$ReadFile = Get-Content -Path $PresetName -Encoding UTF8
# Calculate the string number to add after "Checks -Warning"
$LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber
# Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file
$UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)])
Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
exit
}
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
# Connected User Experiences and Telemetry
# Disabling the "Connected User Experiences and Telemetry" service (DiagTrack) can cause you not being able to get Xbox achievements anymore and affects Feedback Hub
Get-Service -Name DiagTrack | Stop-Service -Force | Set-Service -StartupType Disabled
Get-Service -Name DiagTrack | Stop-Service -Force
Get-Service -Name DiagTrack | Set-Service -StartupType Disabled
# Block connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
@ -834,7 +887,8 @@ function DiagTrackService
"Enable"
{
# Connected User Experiences and Telemetry
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic | Start-Service
Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
Get-Service -Name DiagTrack | Start-Service
# Allow connection for the Unified Telemetry Client Outbound Traffic
Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
@ -2923,6 +2977,9 @@ function UnpinTaskbarShortcuts
$Shortcuts
)
# Extract the localized "Unpin from taskbar" string from shell32.dll
$LocalizedString = [WinAPI.GetStr]::GetString(5387)
foreach ($Shortcut in $Shortcuts)
{
switch ($Shortcut)
@ -2935,7 +2992,7 @@ function UnpinTaskbarShortcuts
$Shell = (New-Object -ComObject Shell.Application).NameSpace("$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar")
$Shortcut = $Shell.ParseName("Microsoft Edge.lnk")
# Extract the localized "Unpin from taskbar" string from shell32.dll
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
$Shortcut.Verbs() | Where-Object -FilterScript {$_.Name -eq "$([WinAPI.GetStr]::GetString(5387))"} | ForEach-Object -Process {$_.DoIt()}
}
}
Store
@ -2946,7 +3003,7 @@ function UnpinTaskbarShortcuts
Start-Job -ScriptBlock {
$Apps = (New-Object -ComObject Shell.Application).NameSpace("shell:::{4234d49b-0245-4df3-b780-3893943456e1}").Items()
# Extract the localized "Unpin from taskbar" string from shell32.dll
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq [WinAPI.GetStr]::GetString(5387)} | ForEach-Object -Process {$_.DoIt()}
($Apps | Where-Object -FilterScript {$_.Name -eq "Microsoft Store"}).Verbs() | Where-Object -FilterScript {$_.Name -eq $using:LocalizedString} | ForEach-Object -Process {$_.DoIt()}
} | Receive-Job -Wait -AutoRemoveJob
}
}
@ -7338,10 +7395,10 @@ function WinPrtScrFolder
if ($PresetName)
{
# Check whether a preset contains the "OneDrive -Uninstall" string uncommented out
if (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall")
if (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch)
{
# The string exists and is commented
$IsOneDriveToUninstall = (Get-Content -Path $PresetName.File -Encoding UTF8 -Force | Select-String -SimpleMatch "OneDrive -Uninstall").Line.StartsWith("#") -eq $false
$IsOneDriveToUninstall = (Select-String -Path $PresetName.File -Pattern "OneDrive -Uninstall" -SimpleMatch).Line.StartsWith("#") -eq $false
}
else
{
@ -9490,7 +9547,7 @@ function Install-WSL
[System.Console]::OutputEncoding = [System.Text.Encoding]::Unicode
$wsl = wsl --list --online
# We need to get the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
# Calculate the string number where the "FRIENDLY NAME" header begins to truncate all other unnecessary strings in the beginning
$LineNumber = ($wsl | Select-String -Pattern "FRIENDLY NAME" -CaseSensitive).LineNumber
# Remove first strings in output from the first to the $LineNumber
$Distros = ($wsl).Replace(" ", "").Replace("* ", "")[($LineNumber)..(($wsl).Count)] | ForEach-Object -Process {

Loading…
Cancel
Save