teeotsa / windows-8-debloat

14 stars 4 forks source link

Enable Windows Defender #4

Closed SlowFox72 closed 1 year ago

SlowFox72 commented 1 year ago

Yes I know I used it at my own risk, but I have just a one question.

Is it possible to reverse the disabling of Windows Defender? I ran the script, it works perfectly, as a workaround I have installed ClamAV, but is there a possibility to make a script to enable again Windows Defender?

kristianrl commented 1 year ago

After executing the script, you can go to Start->Run and enter services.msc. Find the relevant service, right click it and select Properties. In the following window, you can change the Startup Type to Automatic.

SlowFox72 commented 1 year ago

That I have tried but I was not able to because that option was greyed out. What I did is I asked ChatGPT to reverse the script.

Write-Host 'Enable Windows Defender'
$Job = Start-Job -ScriptBlock {
Try
{
# Enable TLS 1.2 Capabilities
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
$WebClient = New-Object System.Net.WebClient
$Link = 'https://github.com/M2Team/NSudo/releases/download/8.2/NSudo_8.2_All_Components.zip'
    # Path
    $ArchiveSavePath = [System.IO.Path]::Combine($env:TEMP, $Link.Substring($Link.LastIndexOf('/') + 1))
    $ExpandPath = [System.IO.Path]::Combine($env:TEMP, 'NSudo_Expand')
    $NSudoLauncher = [System.IO.Path]::Combine($ExpandPath, 'NSudo Launcher', 'Win32', 'NSudoLG.exe')

    # Download
    If (!(Test-Path $ArchiveSavePath))
    {
        $WebClient.DownloadFile($Link, $ArchiveSavePath)
    }

    # Expand
    If (!(Test-Path $ExpandPath))
    {
        Expand-Archive -Path $ArchiveSavePath -DestinationPath $ExpandPath -Force | Out-Null
    }

    # Launch
    Start-Process -FilePath "$NSudoLauncher" -ArgumentList '-U:T -P:E -ShowWindowMode:Hide cmd /c sc config WinDefend start= auto>nul' -Verb RunAs -Wait -WindowStyle Hidden
    Start-Process -FilePath "$NSudoLauncher" -ArgumentList '-U:T -P:E -ShowWindowMode:Hide cmd /c sc config WdNisSvc start= auto>nul' -Verb RunAs -Wait -WindowStyle Hidden

    # Remove Files
    Remove-Item -Path $ArchiveSavePath -Force -Recurse | Out-Null
    Remove-Item -Path $ExpandPath -Force -Recurse | Out-Null
}
Catch
{
    Exit
}
}
Wait-Job -Id $Job.Id | Out-Null

It gave two error messages, but Windows Defender was enabled afterwards

teeotsa commented 1 year ago

Yes, it's possible. Run services.msc with NSudo and enable 'All privileges'

image

image