I wanted to call from batch file powershell script that required administrative privileges.
I needed to check, if it was started as Administrator and also set current directory where the batch is located.
Thanks to couple of stackoverflow questions I’ve got this batch
pushd %~dp0 &:: @http://stackoverflow.com/questions/672693/windows-batch-file-starting-directory-when-run-as-admin
powershell &:: TODO the script to call
net session >nul 2>&1
if %errorLevel% == 0 (
@rem echo Success: Administrative permissions confirmed.
) else (
echo Administrative permissions required.