Dmitry Nefedov 1 year ago
parent
commit
a50595a606
  1. 3
      Wrapper/Localizations/de-DE/ui.json
  2. 3
      Wrapper/Localizations/en-US/ui.json
  3. 3
      Wrapper/Localizations/ru-RU/ui.json
  4. BIN
      Wrapper/SophiaScriptWrapper.exe
  5. 198
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  6. 160
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  7. 157
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  8. 201
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  9. 197
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  10. 198
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

3
Wrapper/Localizations/de-DE/ui.json

@ -67,7 +67,8 @@
"messageBoxDoesNotExist": "existiert nicht",
"messageBoxPresetNotComp": "Voreinstellung ist nicht kompatibel!",
"messageBoxFilesMissingClose": "Die erforderlichen Sophia Script Wrapper-Dateien fehlen. Das Programm wird geschlossen.",
"messageBoxConsoleEmpty": "Die Konsole ist leer.\n Drücken Sie die Schaltfläche Konsole aktualisieren, um ein Skript entsprechend Ihrer Auswahl zu erstellen."
"messageBoxConsoleEmpty": "Die Konsole ist leer.\n Drücken Sie die Schaltfläche Konsole aktualisieren, um ein Skript entsprechend Ihrer Auswahl zu erstellen.",
"messageBoxPowerShellVersionNotInstalled": "Die von Ihnen ausgewählte PowerShell-Version ist nicht installiert."
}
}
]

3
Wrapper/Localizations/en-US/ui.json

@ -67,7 +67,8 @@
"messageBoxDoesNotExist": "does not exist",
"messageBoxPresetNotComp": "preset file is not compatible!",
"messageBoxFilesMissingClose": "Files missing so Sophia Script Wrapper will close.",
"messageBoxConsoleEmpty": "The console is empty.\nClick 'Refresh Console' button to create script with your selections."
"messageBoxConsoleEmpty": "The console is empty.\nClick 'Refresh Console' button to create script with your selections.",
"messageBoxPowerShellVersionNotInstalled": "PowerShell version you selected is not installed."
}
}
]

3
Wrapper/Localizations/ru-RU/ui.json

@ -67,7 +67,8 @@
"messageBoxDoesNotExist": "не существует",
"messageBoxPresetNotComp": "Пресет не совместим!",
"messageBoxFilesMissingClose": "Отсутствуют необходимые файлы Sophia Script Wrapper. Программа будет закрыта.",
"messageBoxConsoleEmpty": "Консоль пуста.\nНажмите кнопку \"Обновить консоль\", чтобы создать скрипт согласно вышему выбору."
"messageBoxConsoleEmpty": "Консоль пуста.\nНажмите кнопку \"Обновить консоль\", чтобы создать скрипт согласно вышему выбору.",
"messageBoxPowerShellVersionNotInstalled": "Выбранная вами версия PowerShell не установлена."
}
}
]

BIN
Wrapper/SophiaScriptWrapper.exe

Binary file not shown.

198
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -100,12 +100,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -171,7 +171,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -402,12 +402,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -422,6 +422,7 @@ public static string GetString(uint strId)
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
@ -439,7 +440,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -710,12 +711,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -738,44 +739,44 @@ public static string GetString(uint strId)
# https://github.com/crazy-max/WindowsSpyBlocker/tree/master/data/hosts
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
}
$update = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$update_v6 = (Invoke-WebRequest @Parameters).Content
@ -816,7 +817,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4384,12 +4385,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4490,7 +4491,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4504,12 +4505,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4610,7 +4611,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4932,8 +4933,8 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
@ -5002,12 +5003,12 @@ public static bool MarkFileDelete (string sourcefile)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -5050,7 +5051,7 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6551,12 +6552,12 @@ function WindowsCapabilities
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6565,7 +6566,7 @@ function WindowsCapabilities
$ButtonContent = $Localization.Install
$ButtonAdd_Click = {InstallButton}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6915,12 +6916,12 @@ function IPv6Component
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6955,7 +6956,7 @@ function IPv6Component
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -9956,12 +9957,12 @@ function InstallVCRedist
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -10008,7 +10009,7 @@ function InstallVCRedist
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -10036,12 +10037,12 @@ function InstallDotNetRuntimes
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -10146,7 +10147,7 @@ function InstallDotNetRuntimes
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11769,17 +11770,17 @@ function HEVC
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11834,6 +11835,7 @@ function HEVC
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
@ -14775,12 +14777,12 @@ function BitmapImageNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -14790,7 +14792,7 @@ function BitmapImageNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -14866,12 +14868,12 @@ function RichTextDocumentNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -14881,7 +14883,7 @@ function RichTextDocumentNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue

160
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -299,12 +299,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -319,6 +319,7 @@ public static string GetString(uint strId)
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2019
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
@ -336,7 +337,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -573,12 +574,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -601,44 +602,44 @@ public static string GetString(uint strId)
# https://github.com/crazy-max/WindowsSpyBlocker/tree/master/data/hosts
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
}
$update = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$update_v6 = (Invoke-WebRequest @Parameters).Content
@ -679,7 +680,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -798,8 +799,7 @@ public static string GetString(uint strId)
$Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "")
# Extract the localized "&Yes" string from shell32.dll
$Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "")
# Extract the localized "Waiting for confirmation" string from shell32.dll
$Script:Wait = [WinAPI.GetStr]::GetString(33252)
$Script:KeyboardArrows = $Localization.KeyboardArrows -f [System.Char]::ConvertFromUtf32(0x1F815), [System.Char]::ConvertFromUtf32(0x1F817)
# Extract the localized "Skip" string from shell32.dll
$Script:Skip = [WinAPI.GetStr]::GetString(16956)
@ -3336,12 +3336,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -3442,7 +3442,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -3456,12 +3456,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -3562,7 +3562,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -5191,12 +5191,12 @@ function WindowsCapabilities
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -5205,7 +5205,7 @@ function WindowsCapabilities
$ButtonContent = $Localization.Install
$ButtonAdd_Click = {InstallButton}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -5555,12 +5555,12 @@ function IPv6Component
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -5595,7 +5595,7 @@ function IPv6Component
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -8255,12 +8255,12 @@ function InstallVCRedist
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -8307,7 +8307,7 @@ function InstallVCRedist
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -8335,12 +8335,12 @@ function InstallDotNetRuntimes
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -8445,7 +8445,7 @@ function InstallDotNetRuntimes
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11205,12 +11205,12 @@ function BitmapImageNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -11220,7 +11220,7 @@ function BitmapImageNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11296,12 +11296,12 @@ function RichTextDocumentNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -11311,7 +11311,7 @@ function RichTextDocumentNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue

157
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -299,12 +299,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -319,6 +319,7 @@ public static string GetString(uint strId)
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC2021
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
@ -336,7 +337,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -573,12 +574,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -601,44 +602,44 @@ public static string GetString(uint strId)
# https://github.com/crazy-max/WindowsSpyBlocker/tree/master/data/hosts
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
}
$update = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$update_v6 = (Invoke-WebRequest @Parameters).Content
@ -679,7 +680,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -3706,12 +3707,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -3812,7 +3813,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -3826,12 +3827,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -3932,7 +3933,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -5577,12 +5578,12 @@ function WindowsCapabilities
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -5591,7 +5592,7 @@ function WindowsCapabilities
$ButtonContent = $Localization.Install
$ButtonAdd_Click = {InstallButton}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -5941,12 +5942,12 @@ function IPv6Component
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -5981,7 +5982,7 @@ function IPv6Component
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -8879,12 +8880,12 @@ function InstallVCRedist
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -8931,7 +8932,7 @@ function InstallVCRedist
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -8959,12 +8960,12 @@ function InstallDotNetRuntimes
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -9069,7 +9070,7 @@ function InstallDotNetRuntimes
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -12374,12 +12375,12 @@ function BitmapImageNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -12389,7 +12390,7 @@ function BitmapImageNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -12465,12 +12466,12 @@ function RichTextDocumentNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -12480,7 +12481,7 @@ function RichTextDocumentNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue

201
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -96,12 +96,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -167,7 +167,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -403,12 +403,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -423,6 +423,7 @@ public static string GetString(uint strId)
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_7
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
@ -440,7 +441,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -711,12 +712,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -739,44 +740,44 @@ public static string GetString(uint strId)
# https://github.com/crazy-max/WindowsSpyBlocker/tree/master/data/hosts
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
}
$update = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$update_v6 = (Invoke-WebRequest @Parameters).Content
@ -817,7 +818,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4388,12 +4389,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4494,7 +4495,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4508,12 +4509,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4614,7 +4615,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4936,8 +4937,8 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
@ -5006,12 +5007,12 @@ public static bool MarkFileDelete (string sourcefile)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -5054,7 +5055,7 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6555,13 +6556,12 @@ function WindowsCapabilities
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
SslProtocol = "Tls12"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6570,7 +6570,7 @@ function WindowsCapabilities
$ButtonContent = $Localization.Install
$ButtonAdd_Click = {InstallButton}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6920,12 +6920,12 @@ function IPv6Component
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6960,7 +6960,7 @@ function IPv6Component
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -9961,12 +9961,12 @@ function InstallVCRedist
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -10013,7 +10013,7 @@ function InstallVCRedist
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -10041,12 +10041,12 @@ function InstallDotNetRuntimes
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -10151,7 +10151,7 @@ function InstallDotNetRuntimes
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11794,17 +11794,17 @@ function HEVC
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11859,6 +11859,7 @@ function HEVC
Write-Information -MessageData "" -InformationAction Continue
# Extract the localized "Please wait..." string from shell32.dll
Write-Verbose -Message ([WinAPI.GetStr]::GetString(12612)) -Verbose
Write-Verbose -Message $Localization.HEVCDownloading -Verbose
$DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}"
@ -14800,13 +14801,12 @@ function BitmapImageNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
SslProtocol = "Tls12"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -14816,7 +14816,7 @@ function BitmapImageNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -14892,13 +14892,12 @@ function RichTextDocumentNewContext
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
SslProtocol = "Tls12"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -14908,7 +14907,7 @@ function RichTextDocumentNewContext
Get-WindowsCapability -Online -Name "Microsoft.Windows.WordPad*" | Add-WindowsCapability -Online
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue

197
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -99,12 +99,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -170,7 +170,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -202,12 +202,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -253,7 +253,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "microsoft.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -488,12 +488,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -508,6 +508,7 @@ public static string GetString(uint strId)
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
@ -525,7 +526,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -762,12 +763,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -790,44 +791,44 @@ public static string GetString(uint strId)
# https://github.com/crazy-max/WindowsSpyBlocker/tree/master/data/hosts
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
}
$update = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$update_v6 = (Invoke-WebRequest @Parameters).Content
@ -868,7 +869,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4095,12 +4096,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4201,7 +4202,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4215,12 +4216,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4321,7 +4322,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4643,8 +4644,8 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
@ -4713,12 +4714,12 @@ public static bool MarkFileDelete (string sourcefile)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4761,7 +4762,7 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6259,12 +6260,12 @@ function WindowsCapabilities
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6273,7 +6274,7 @@ function WindowsCapabilities
$ButtonContent = $Localization.Install
$ButtonAdd_Click = {InstallButton}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6827,12 +6828,12 @@ function IPv6Component
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6867,7 +6868,7 @@ function IPv6Component
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -9744,12 +9745,12 @@ function InstallVCRedist
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -9796,7 +9797,7 @@ function InstallVCRedist
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -9824,12 +9825,12 @@ function InstallDotNetRuntimes
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -9934,7 +9935,7 @@ function InstallDotNetRuntimes
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -10048,12 +10049,12 @@ function Install-WSA
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -10070,7 +10071,7 @@ function Install-WSA
# Open Misrosoft Store WSA page to install it manually
Start-Process -FilePath ms-windows-store://pdp/?ProductId=9P3395VX91NR
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11446,17 +11447,17 @@ function HEVC
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue

198
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -95,12 +95,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -166,7 +166,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://c2rsetup.officeapps.live.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -198,12 +198,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -249,7 +249,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "microsoft.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -489,12 +489,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -509,6 +509,7 @@ public static string GetString(uint strId)
}
$LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_7
$CurrentRelease = (Get-Module -Name Sophia).Version.ToString()
if ([System.Version]$LatestRelease -gt [System.Version]$CurrentRelease)
{
Write-Warning -Message $Localization.UnsupportedRelease
@ -526,7 +527,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.NoResponse -f "https://github.com") -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -763,12 +764,12 @@ public static string GetString(uint strId)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -791,44 +792,44 @@ public static string GetString(uint strId)
# https://github.com/crazy-max/WindowsSpyBlocker/tree/master/data/hosts
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$extra_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$spy_v6 = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt"
UseBasicParsing = $true
Verbose = $true
}
$update = (Invoke-WebRequest @Parameters).Content
$Parameters = @{
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
Uri = "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update_v6.txt"
UseBasicParsing = $true
Verbose = $true
}
$update_v6 = (Invoke-WebRequest @Parameters).Content
@ -869,7 +870,7 @@ public static string GetString(uint strId)
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4096,12 +4097,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4202,7 +4203,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4216,12 +4217,12 @@ function Cursors
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4322,7 +4323,7 @@ function Cursors
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -4644,8 +4645,8 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path $Path -Recurse -Force -ErrorAction Ignore
Unregister-ScheduledTask -TaskName *OneDrive* -Confirm:$false -ErrorAction Ignore
# Getting the OneDrive folder path
$OneDriveFolder = Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
@ -4714,12 +4715,12 @@ public static bool MarkFileDelete (string sourcefile)
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -4762,7 +4763,7 @@ public static bool MarkFileDelete (string sourcefile)
Remove-Item -Path "$DownloadsFolder\OneDriveSetup.exe" -Force
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6260,13 +6261,12 @@ function WindowsCapabilities
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
SslProtocol = "Tls13"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6275,7 +6275,7 @@ function WindowsCapabilities
$ButtonContent = $Localization.Install
$ButtonAdd_Click = {InstallButton}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -6829,12 +6829,12 @@ function IPv6Component
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -6869,7 +6869,7 @@ function IPv6Component
Write-Error -Message ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -ErrorAction SilentlyContinue
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -9746,12 +9746,12 @@ function InstallVCRedist
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -9798,7 +9798,7 @@ function InstallVCRedist
Get-ChildItem -Path $Paths -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -9826,12 +9826,12 @@ function InstallDotNetRuntimes
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -9936,7 +9936,7 @@ function InstallDotNetRuntimes
Get-ChildItem -Path $Paths -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -10050,12 +10050,12 @@ function Install-WSA
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
@ -10072,7 +10072,7 @@ function Install-WSA
# Open Misrosoft Store WSA page to install it manually
Start-Process -FilePath ms-windows-store://pdp/?ProductId=9P3395VX91NR
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue
@ -11468,17 +11468,17 @@ function HEVC
{
# Check the internet connection
$Parameters = @{
Uri = "https://www.cloudflare.com"
Method = "Head"
DisableKeepAlive = $true
UseBasicParsing = $true
Name = "dns.msftncsi.com"
Server = "1.1.1.1"
DnsOnly = $true
ErrorAction = "Stop"
}
if (-not (Invoke-WebRequest @Parameters).StatusDescription)
if ((Resolve-DnsName @Parameters).IPAddress -notcontains "131.107.255.255")
{
return
}
}
catch [System.Net.WebException]
catch [System.ComponentModel.Win32Exception]
{
Write-Warning -Message $Localization.NoInternetConnection
Write-Error -Message $Localization.NoInternetConnection -ErrorAction SilentlyContinue

Loading…
Cancel
Save