Browse Source

Added new checks

Improved Checks

Added new checks

fixed typo
pull/469/head 6.4.3
Dmitry Nefedov 1 year ago
parent
commit
19aa9741fb
  1. 99
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 6
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 6
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 102
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 99
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 102
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

99
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -540,6 +540,90 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# Automatically manage paging file size for all drives
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).AutomaticManagedPageFile)
{
Get-CimInstance -ClassName CIM_ComputerSystem | Set-CimInstance -Property @{AutomaticManagedPageFile = $true}
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")
{
return
}
else
{
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
try
{
# Download Microsoft Edge Stable x64
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = "https://c2rsetup.officeapps.live.com/c2r/downloadEdge.aspx?platform=Default&source=EdgeStablePage&Channel=Stable&language=$((Get-WinSystemLocale).TwoLetterISOLanguageName)"
OutFile = "$DownloadsFolder\MicrosoftEdgeSetup.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-Webrequest @Parameters
# Install Microsoft Edge Stable x64
Start-Process -FilePath "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Wait
Get-Process -Name msedge | Stop-Process -Force -ErrorAction Ignore
Start-Sleep -Seconds 5
& "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
Remove-Item -Path "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com")
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Display a warning message about whether a user has customized the preset file
if ($Warning)
{
@ -576,21 +660,6 @@ 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
}
#endregion Checks

6
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -546,6 +546,12 @@ public static string GetString(uint strId)
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# Automatically manage paging file size for all drives
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).AutomaticManagedPageFile)
{
Get-CimInstance -ClassName CIM_ComputerSystem | Set-CimInstance -Property @{AutomaticManagedPageFile = $true}
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore

6
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -546,6 +546,12 @@ public static string GetString(uint strId)
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# Automatically manage paging file size for all drives
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).AutomaticManagedPageFile)
{
Get-CimInstance -ClassName CIM_ComputerSystem | Set-CimInstance -Property @{AutomaticManagedPageFile = $true}
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore

102
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -546,6 +546,90 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# Automatically manage paging file size for all drives
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).AutomaticManagedPageFile)
{
Get-CimInstance -ClassName CIM_ComputerSystem | Set-CimInstance -Property @{AutomaticManagedPageFile = $true}
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")
{
return
}
else
{
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
try
{
# Download Microsoft Edge Stable x64
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = "https://c2rsetup.officeapps.live.com/c2r/downloadEdge.aspx?platform=Default&source=EdgeStablePage&Channel=Stable&language=$((Get-WinSystemLocale).TwoLetterISOLanguageName)"
OutFile = "$DownloadsFolder\MicrosoftEdgeSetup.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-Webrequest @Parameters
# Install Microsoft Edge Stable x64
Start-Process -FilePath "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Wait
Get-Process -Name msedge | Stop-Process -Force -ErrorAction Ignore
Start-Sleep -Seconds 5
& "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
Remove-Item -Path "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com")
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Display a warning message about whether a user has customized the preset file
if ($Warning)
{
@ -582,24 +666,6 @@ 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Import PowerShell 5.1 modules
Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
}
#endregion Checks

99
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -594,6 +594,90 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# Automatically manage paging file size for all drives
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).AutomaticManagedPageFile)
{
Get-CimInstance -ClassName CIM_ComputerSystem | Set-CimInstance -Property @{AutomaticManagedPageFile = $true}
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")
{
return
}
else
{
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
try
{
# Download Microsoft Edge Stable x64
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = "https://c2rsetup.officeapps.live.com/c2r/downloadEdge.aspx?platform=Default&source=EdgeStablePage&Channel=Stable&language=$((Get-WinSystemLocale).TwoLetterISOLanguageName)"
OutFile = "$DownloadsFolder\MicrosoftEdgeSetup.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-Webrequest @Parameters
# Install Microsoft Edge Stable x64
Start-Process -FilePath "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Wait
Get-Process -Name msedge | Stop-Process -Force -ErrorAction Ignore
Start-Sleep -Seconds 5
& "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
Remove-Item -Path "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com")
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Display a warning message about whether a user has customized the preset file
if ($Warning)
{
@ -630,21 +714,6 @@ 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
}
#endregion Checks

102
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -599,6 +599,90 @@ public static string GetString(uint strId)
Add-Type @Signature
}
# 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# Automatically manage paging file size for all drives
if (-not (Get-CimInstance -ClassName CIM_ComputerSystem).AutomaticManagedPageFile)
{
Get-CimInstance -ClassName CIM_ComputerSystem | Set-CimInstance -Property @{AutomaticManagedPageFile = $true}
}
# Check if Microsoft Edge as being a system component was removed by harmful tweakers
if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")
{
return
}
else
{
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
try
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.google.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
{
return
}
try
{
# Download Microsoft Edge Stable x64
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
$Parameters = @{
Uri = "https://c2rsetup.officeapps.live.com/c2r/downloadEdge.aspx?platform=Default&source=EdgeStablePage&Channel=Stable&language=$((Get-WinSystemLocale).TwoLetterISOLanguageName)"
OutFile = "$DownloadsFolder\MicrosoftEdgeSetup.exe"
UseBasicParsing = $true
Verbose = $true
}
Invoke-Webrequest @Parameters
# Install Microsoft Edge Stable x64
Start-Process -FilePath "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Wait
Get-Process -Name msedge | Stop-Process -Force -ErrorAction Ignore
Start-Sleep -Seconds 5
& "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" --no-first-run --noerrdialogs --no-default-browser-check --start-maximized
Remove-Item -Path "$DownloadsFolder\MicrosoftEdgeSetup.exe" -Force
Start-Process -FilePath "https://t.me/sophia_chat"
Start-Process -FilePath "https://discord.gg/sSryhaEv79"
}
catch [System.Net.WebException]
{
Write-Warning -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com")
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
}
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
# Display a warning message about whether a user has customized the preset file
if ($Warning)
{
@ -635,24 +719,6 @@ 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
Get-Service -Name SysMain | Start-Service
Start-Process -FilePath "https://www.outsidethebox.ms/19318/"
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Import PowerShell 5.1 modules
Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell
# Save all opened folders in order to restore them after File Explorer restart
$Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke()
}
#endregion Checks

Loading…
Cancel
Save