Skip to content

Commit bcd2dfa

Browse files
committed
run mpcmdrun command if the exe exists
prevents errors if disabling defender using '--force' on an already disabled environment. why? sometimes our defender package doesn't get removed when enabling Defender and reinstalling the package fixes it
1 parent 770a89b commit bcd2dfa

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

common/lib/src/services/security_service.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,10 @@ class SecurityService implements SetupService {
261261
await _shell.run(
262262
'start /WAIT /MIN /B "" "%systemroot%\\System32\\gpupdate.exe" /Target:Computer /Force');
263263

264-
await _shell.run(
265-
"PowerShell -EP Unrestricted -NonInteractive -NoLogo -NoP -C 'Start-Process -FilePath \"$_mpCmdRunString\" -ArgumentList \"-RemoveDefinitions -All\" -NoNewWindow -Wait'");
264+
if (await File(_mpCmdRunString).exists()) {
265+
await _shell.run(
266+
"PowerShell -EP Unrestricted -NonInteractive -NoLogo -NoP -C 'Start-Process -FilePath \"$_mpCmdRunString\" -ArgumentList \"-RemoveDefinitions -All\" -NoNewWindow -Wait'");
267+
}
266268

267269
await _shell.run(
268270
'"$directoryExe\\MinSudo.exe" --NoLogo --TrustedInstaller reg add "HKLM\\SOFTWARE\\Microsoft\\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f');

0 commit comments

Comments
 (0)