Skip to content

Commit

Permalink
fix(Toggle Defender): make uninstalling package not prompt for restart
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Aug 2, 2023
1 parent 95f8be9 commit d0d11a8
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ $AtlasPackageName = 'Z-Atlas-NoDefender-Package'
$AtlasModules = "$env:windir\AtlasModules"
$onlineSxS = "$AtlasModules\Scripts\online-sxs.cmd"
$packagesPath = "$AtlasModules\Packages"
$ProgressPreference = 'SilentlyContinue'

function PauseNul ($message = "Press any key to exit... ") {
Write-Host $message -NoNewLine
Expand All @@ -53,11 +54,11 @@ function UninstallPackage {
} else {
foreach ($package in $packages) {
try {
Remove-WindowsPackage -Online -PackageName $package *>$null
Remove-WindowsPackage -Online -PackageName $package -NoRestart -LogLevel 1 *>$null
} catch {
Write-Host "Something went wrong removing the package: $package" -ForegroundColor Red
Write-Host "$_`n" -ForegroundColor Red
if ($Enable -or $Disable) {return 1} else {PauseNul; exit 1}
if (!($Enable -or $Disable)) {PauseNul}; exit 1
}
}
}
Expand All @@ -70,8 +71,7 @@ function InstallPackage {
& $onlineSxS "$latestCabPath" -Silent
} catch {
Write-Host "`nSomething went wrong whilst adding the Defender package.`nPlease report the error above to the Atlas team." -ForegroundColor Yellow
PauseNul
exit 1
if (!($Enable -or $Disable)) {PauseNul}; exit 1
}
}

Expand Down Expand Up @@ -132,14 +132,20 @@ function Menu {
Write-Host "Are you sure that you want to disable Defender?" -ForegroundColor Red
Write-Host "Although disabling Windows Defender will improve performance and convienience, it's important for security.`n"

Pause; Clear-Host; InstallPackage

Pause
Clear-Host
InstallPackage
SetDefenderConfigInRegistry -SetValue $false

Finish
}
# Enable Defender
2 {
Clear-Host; UninstallPackage; SetDefenderConfigInRegistry -SetValue $true; Finish
Clear-Host
UninstallPackage
SetDefenderConfigInRegistry -SetValue $true

Finish
}
default {
# Do nothing
Expand Down

0 comments on commit d0d11a8

Please sign in to comment.