Advertisement
pf100

WinDefendCheck.cmd

May 14th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. @echo off
  2. color 1F
  3. :::::::::::::::::::::::::::::::::::::::::
  4. :: Automatically check & get admin rights
  5. :::::::::::::::::::::::::::::::::::::::::
  6. :: ECHO.
  7. :: ECHO =============================
  8. :: ECHO Running Admin shell
  9. :: ECHO =============================
  10. :: Check Privileges
  11. :: Get Privileges
  12. :: and
  13. :: Invoke UAC for Privilege Escalation
  14. :: Notify if error escalating
  15. :: and prevent looping if escalation fails
  16. ::::::::::::::::::::::::::::
  17. set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
  18. fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
  19. :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
  20. If "%1"=="%params%" (echo Elevating UAC for Administrator Privileges failed&echo Right click on the script and select 'Run as administrator'&echo Press any key to exit...&pause>nul 2>&1&exit)
  21. cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs"&exit
  22. :GotPrivileges
  23. ::::::::::::::::::::::::::::
  24. sc query > "%~dp0%servicedump.txt"
  25. find /i "windefend" "%~dp0%servicedump.txt" > nul & if errorlevel 1 (
  26. schtasks /Change /TN "WDU" /Disable >nul 2>&1
  27. ) else (
  28. schtasks /Change /TN "WDU" /Enable >nul 2>&1
  29. )
  30. del /f /q "%~dp0%servicedump.txt" >nul 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement