-
-
Save vavavr00m/864bb39c9672610ae25b144c35ee1fad to your computer and use it in GitHub Desktop.
Stop adobe running in the background and Block adobe in Host File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Priority { | |
$ErrorActionPreference = 'SilentlyContinue' | |
foreach ($root in 'HKCU', 'HKLM', 'HKU', 'HKCR') { | |
New-PSDrive -PSProvider Registry -Name $root -Root "HKEY_$root" | Out-Null | |
} | |
Set-ExecutionPolicy RemoteSigned -Force -Scope CurrentUser | |
$ErrorActionPreference = 'Continue' | |
} | |
Priority | |
Function Silent { $Global:ProgressPreference = 'SilentlyContinue' } | |
Silent | |
Function StopAdobeApps { | |
Write-Host "Stopping Adobe apps..." -NoNewline | |
try { | |
# Stop running process | |
Get-Process * | Where-Object { $_.CompanyName -match "Adobe" -or $_.Path -match "Adobe" } | Stop-Process | |
# Disable services | |
Get-Service * | Where-Object { ($_.Name -match "Adobe" -or $_.DisplayName -match "Adobe") -and $_.StartType -ne 'Disabled' } | ForEach-Object { Set-Service -Name $_.Name -StartupType Disabled; Stop-Service -Name $_.Name } | |
# Disable task schedules | |
Get-ScheduledTask * | Where-Object { ($_.TaskName -match "Adobe" -or $_.TaskPath -match "Adobe") -and $_.State -ne 'Disabled' } | ForEach-Object { Disable-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath } | |
# Disable startup apps | |
@('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run', 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run32') | ForEach-Object { $path = $_; Get-ItemProperty -Path $path | ForEach-Object { $_.PSObject.Properties | Where-Object { $_.Name -match "Adobe" -and $_.Value[0] -ne 3 } | ForEach-Object { Set-ItemProperty -Path $path -Name $_.Name -Value ([byte[]](0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)) } } } | |
Write-Host "[DONE]" -ForegroundColor Green | |
} catch { Write-Host "[WARNING] $_" -ForegroundColor Red } | |
} | |
Function BlockAdobeHosts { | |
Write-Host "Blocking Adobe in Host File..." -NoNewline | |
$file = "$env:windir\System32\drivers\etc\hosts" | |
if ((Test-Path $file) -and (-not (Get-Item $file).IsReadOnly)) { | |
try { | |
$filteredUrls = (Invoke-WebRequest -Uri "https://a.dove.isdumb.one/winhosts.txt").Content -split "`r?`n" | Where-Object { $_ -match "^0\.0\.0\.0" } | |
$contentToInsert = "`r`n# [start-block-adobe]`r`n" + ($filteredUrls -join "`r`n") + "`r`n# [end-block-adobe]" | |
Set-Content -Path $file -Value ([regex]::replace((Get-Content -Path $file -Raw), "(?s)# \[start-block-adobe\].*?# \[end-block-adobe\]", "") + $contentToInsert) | |
Write-Host "[DONE]" -ForegroundColor Green | |
} catch { Write-Host "[WARNING] $_" -ForegroundColor Red } | |
} else { Write-Host "[WARNING] Host file is either not accessible or read-only" -ForegroundColor Red } | |
} | |
Function StopAdobe { | |
$response = Read-Host "Do you want to stop Adobe? (y/n)" | |
if ($response -match "^[Yy]$") { StopAdobeApps; BlockAdobeHosts } | |
elseif ($response -match "^[Nn]$") { Write-Host "[Adobe will not be stopped]" -ForegroundColor Red } | |
else { Write-Host "Invalid input. Please enter 'y' or 'n'." ; StopAdobe } | |
} | |
StopAdobe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment