Tag: batch

Microsoft Windows

Invoking UAC for Privilege Escalation in batch file

@echo off at >nul if %errorlevel% == 0 goto run_elevated   echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getUACpriv.vbs" echo UAC.ShellExecute %0, "", "", "runas", 1 >> "%temp%getUACpriv.vbs"   ECHO Privilege Escalation   "%temp%getUACpriv.vbs" >nul exit /B   :run_elevated del "%temp%getUACpriv.vbs" 2>nul CD "%~dp0"   REM your commands   pause>nul@echo off at >nul if %errorlevel% == …

Microsoft Windows

Start or Stop Windows Service using batch file

Start Windows Service Open notepad and create a new file named for ex start_my_service.bat. Paste in file the following lines: @echo off echo "starting my_service" net start "my_service" echo "done" @echo on   pause@echo off echo "starting my_service" net start "my_service" echo "done" @echo on pause Save the file, right click on it and select …