Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- color 1F
- :::::::::::::::::::::::::::::::::::::::::
- :: Automatically check & get admin rights
- :::::::::::::::::::::::::::::::::::::::::
- :: ECHO.
- :: ECHO =============================
- :: ECHO Running Admin shell
- :: ECHO =============================
- :: Check Privileges
- :: Get Privileges
- :: and
- :: Invoke UAC for Privilege Escalation
- :: Notify if error escalating
- :: and prevent looping if escalation fails
- ::::::::::::::::::::::::::::
- set "params=Problem_with_elevating_UAC_for_Administrator_Privileges"&if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
- fsutil dirty query %systemdrive% >nul 2>&1 && goto :GotPrivileges
- :: The following test is to avoid infinite looping if elevating UAC for Administrator Privileges failed
- 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)
- cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs"&exit
- :GotPrivileges
- ::::::::::::::::::::::::::::
- sc query > "%~dp0%servicedump.txt"
- find /i "windefend" "%~dp0%servicedump.txt" > nul & if errorlevel 1 (
- schtasks /Change /TN "WDU" /Disable >nul 2>&1
- ) else (
- schtasks /Change /TN "WDU" /Enable >nul 2>&1
- )
- del /f /q "%~dp0%servicedump.txt" >nul 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement