diff --git a/script.cmd b/script.cmd new file mode 100644 index 0000000..9b98d9c --- /dev/null +++ b/script.cmd @@ -0,0 +1,36 @@ +pushd "%~dp0" +@echo off +goto :Start + +-------------------------------------------------- +Returning current username if privileged rights are exist +or +returning error, if privileged rights are not exist + +Positional parameters: + [1] qn - execution without pauses + +Administrator rights required. +-------------------------------------------------- + +:Start + set basename=%~n0 + +:Admin_Check + openfiles >nul 2>&1 + if %errorLevel% == 0 ( + set code=0 + ) else ( + set code=5 + cls + echo Restart this as Administrator! + goto :Exit + ) + +:Show_Username + echo Running %basename% as %username% + +:Exit +if "%~1" NEQ "qn" pause +popd +exit %code% \ No newline at end of file