From 7122e96ad163cc92b458f20d5957fa383ef1f754 Mon Sep 17 00:00:00 2001 From: "pavel.muhortov" Date: Thu, 5 Jan 2023 19:59:52 +0300 Subject: [PATCH] update template --- script.cmd | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 script.cmd 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