I would recommend something based off of this script:
@echo off
NET FILE 1>NUL 2>NUL
IF ERRORLEVEL 1 GOTO no
GOTO yes
:no
echo no
pause
goto exit
:yes
echo yes
pause
goto exit
:exit
Question
I need a code in the space below to tell if the batch file is elevated or not. I am making a program so that if it is elevated it does something one way and if it is not it does it the other way. Does anyone know a code I could use.
@echo off
:no
echo no
pause
goto exit
:yes
echo yes
pause
goto exit
:exit
Solution
I would recommend something based off of this script:
@echo off
NET FILE 1>NUL 2>NUL
IF ERRORLEVEL 1 GOTO no
GOTO yes
:no
echo no
pause
goto exit
:yes
echo yes
pause
goto exit
:exit
OTHER TIPS
Run some command which requires elevated privilege & check ERRORLEVEL
@echo off
at > nul
if %ERRORLEVEL% EQU 0 goto elevated
REM do non-elevated stuff
goto end
:elevated
REM do elevated stuff
:end