Advertisement

How to check in a batch file if you are running it elevated

Sometimes it is useful to check in a batch file if it was started from an elevated command prompt or as an administrator. I would like to share with you a trick which I am using to do this. The main idea of my trick is based on the value of the special environment variable %errorlevel% which stores the exit code for most console apps and commands. Let's see this in action.

css.php
Using Telegram? Subscribe to the blog channel!
0000d
0000h
0000m
0000s
Hello. Add your message here.