mirror of
https://github.com/SpotX-Official/SpotX.git
synced 2026-06-18 21:30:05 +10:00
fix the hosts file
- Attempt to fix the hosts file https://github.com/amd64fox/SpotX/issues/52
This commit is contained in:
@@ -84,4 +84,6 @@ Good luck to you.
|
|||||||
UpdateError = "Failed to block updates"
|
UpdateError = "Failed to block updates"
|
||||||
NoSpotifyExe = "Could not find Spotify.exe"
|
NoSpotifyExe = "Could not find Spotify.exe"
|
||||||
InstallComplete = "installation completed"
|
InstallComplete = "installation completed"
|
||||||
|
HostDel = "Unwanted URLs found in hosts file, trying to remove them..."
|
||||||
|
HostError = "Something went wrong while editing the hosts file, edit it manually"
|
||||||
```
|
```
|
||||||
|
|||||||
+26
@@ -209,6 +209,8 @@ function Set-ScriptLanguageStrings {
|
|||||||
UpdateError = "Failed to block updates"
|
UpdateError = "Failed to block updates"
|
||||||
NoSpotifyExe = "Could not find Spotify.exe"
|
NoSpotifyExe = "Could not find Spotify.exe"
|
||||||
InstallComplete = "installation completed"
|
InstallComplete = "installation completed"
|
||||||
|
HostDel = "Unwanted URLs found in hosts file, trying to remove them..."
|
||||||
|
HostError = "Something went wrong while editing the hosts file, edit it manually"
|
||||||
}
|
}
|
||||||
|
|
||||||
$langStringsRU = [PSCustomObject]@{
|
$langStringsRU = [PSCustomObject]@{
|
||||||
@@ -269,6 +271,8 @@ function Set-ScriptLanguageStrings {
|
|||||||
UpdateError = "Не удалось заблокировать обновления"
|
UpdateError = "Не удалось заблокировать обновления"
|
||||||
NoSpotifyExe = "Spotify.exe не найден"
|
NoSpotifyExe = "Spotify.exe не найден"
|
||||||
InstallComplete = "Установка завершена"
|
InstallComplete = "Установка завершена"
|
||||||
|
HostDel = "В файле hosts найдены нежелательные Url-адреса, попытка их удалить..."
|
||||||
|
HostError = "Что-то пошло не так при редактировании файла hosts, отредактируйте его вручную"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,6 +556,28 @@ if ($win11 -or $win10 -or $win8_1 -or $win8) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Attempt to fix the hosts file
|
||||||
|
$pathHosts = "$Env:windir\System32\Drivers\Etc\hosts"
|
||||||
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
$testHosts = Test-Path -Path $pathHosts
|
||||||
|
|
||||||
|
if ($testHosts) {
|
||||||
|
$hosts = Get-Content -Path $pathHosts
|
||||||
|
|
||||||
|
if ($hosts -match '.+scdn.+' -or $hosts -match '.+spotify.+' ) {
|
||||||
|
Write-Host ($lang).HostDel`n
|
||||||
|
|
||||||
|
try {
|
||||||
|
$hosts = $hosts -replace '.+scdn.+', '' -replace '.+spotify.+', ''
|
||||||
|
Set-Content -Path $pathHosts -Value $hosts -Force
|
||||||
|
$hosts | Where-Object { $_.trim() -ne "" } | Set-Content -Path $pathHosts -Force
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host ($lang).HostError`n -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Unique directory name based on time
|
# Unique directory name based on time
|
||||||
Push-Location -LiteralPath $env:TEMP
|
Push-Location -LiteralPath $env:TEMP
|
||||||
New-Item -Type Directory -Name "SpotX_Temp-$(Get-Date -UFormat '%Y-%m-%d_%H-%M-%S')" | Convert-Path | Set-Location
|
New-Item -Type Directory -Name "SpotX_Temp-$(Get-Date -UFormat '%Y-%m-%d_%H-%M-%S')" | Convert-Path | Set-Location
|
||||||
|
|||||||
Reference in New Issue
Block a user