diff --git a/Download_Latest_Sophia.ps1 b/Download_Latest_Sophia.ps1 index aa940e4a..2c591edc 100644 --- a/Download_Latest_Sophia.ps1 +++ b/Download_Latest_Sophia.ps1 @@ -158,7 +158,23 @@ if (Test-Path -Path "$DownloadsFolder\$($Version)_Latest") New-Item -Path "$DownloadsFolder\SophiaScriptTemp\Sophia-Script-for-Windows-master\src\$Version\Binaries" -ItemType Directory -Force -& "$env:SystemRoot\System32\tar.exe" -C "$DownloadsFolder\SophiaScriptTemp" -xf "$DownloadsFolder\master.zip" "Sophia-Script-for-Windows-master/src/$Version" +try +{ + & "$env:SystemRoot\System32\tar.exe" -C "$DownloadsFolder\SophiaScriptTemp" -xf "$DownloadsFolder\master.zip" "Sophia-Script-for-Windows-master/src/$Version" +} +catch +{ + Write-Verbose -Message "Archive cannot be expanded. Probably, this was caused by your antivirus. Please update its definitions and try again." -Verbose + + # Check for updates + Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan + + # Open t"Windows Update" page + Start-Process -FilePath "ms-settings:windowsupdate" + + pause + exit +} # Download LGPO # https://techcommunity.microsoft.com/t5/microsoft-security-baselines/lgpo-exe-local-group-policy-object-utility-v1-0/ba-p/701045 diff --git a/Download_Sophia.ps1 b/Download_Sophia.ps1 index e52252e2..24cb3c15 100644 --- a/Download_Sophia.ps1 +++ b/Download_Sophia.ps1 @@ -51,6 +51,18 @@ $LatestGitHubRelease = (Invoke-RestMethod @Parameters).tag_name if (-not $LatestGitHubRelease) { Write-Warning -Message "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest is unreachable. Please fix connection or change your DNS records." + Write-Information -MessageData "" -InformationAction Continue + + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) + { + $DNS = (Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses + } + else + { + $DNS = (Get-NetAdapter -Physical | Get-NetIPInterface -AddressFamily IPv4 | Get-DnsClientServerAddress -AddressFamily IPv4).ServerAddresses + } + Write-Warning -Message "Your DNS are $(if ($DNS.Count -gt 1) {$DNS -join ', '} else {$DNS})" + pause exit } @@ -222,12 +234,29 @@ if (-not (Test-Path -Path "$DownloadsFolder\Sophia.Script.zip")) exit } -$Parameters = @{ - Path = "$DownloadsFolder\Sophia.Script.zip" - DestinationPath = "$DownloadsFolder" - Force = $true +try +{ + $Parameters = @{ + Path = "$DownloadsFolder\Sophia.Script.zip" + DestinationPath = "$DownloadsFolder" + ErrorAction = "Stop" + Force = $true + } + Expand-Archive @Parameters +} +catch +{ + Write-Verbose -Message "Archive cannot be expanded. Probably, this was caused by your antivirus. Please update its definitions and try again." -Verbose + + # Check for updates + Start-Process -FilePath "$env:SystemRoot\System32\UsoClient.exe" -ArgumentList StartInteractiveScan + + # Open t"Windows Update" page + Start-Process -FilePath "ms-settings:windowsupdate" + + pause + exit } -Expand-Archive @Parameters Remove-Item -Path "$DownloadsFolder\Sophia.Script.zip" -Force diff --git a/Misc/Cursors.zip b/Misc/Cursors.zip deleted file mode 100644 index 0dbdb995..00000000 Binary files a/Misc/Cursors.zip and /dev/null differ diff --git a/Misc/dark.zip b/Misc/dark.zip index eb094d30..96aaadfa 100644 Binary files a/Misc/dark.zip and b/Misc/dark.zip differ diff --git a/Misc/light.zip b/Misc/light.zip index d82a9f4b..42f52de3 100644 Binary files a/Misc/light.zip and b/Misc/light.zip differ