Monthly Archives: February 2023
Here is a one-line batch script in MS-DOS command to check the elevated status and exit the script if the user is not an administrator.

net session >nul 2>&1 || exit

 

This script runs the net session command, which returns an error message if the user is not an administrator. The || operator allows the script to execute the exit command if the previous command returns an error code. The >nul 2>&1 redirects the output of the net session command to null so that it doesn’t display any error messages on the screen.

Posted on February 4, 2023, 7:47 pm By
Categories: tech tips Tags: ,