Is there a way that a batch file called from another file can halt execution of the parent without closing the entire terminal session?
Something along the lines of this, which would require an admin to run the script:
@echo off
:: mybatch.bat
call admintest.bat
echo I am still running
@echo off
:: admintest.bat
net session >nul 2>&1
if not %errorlevel% == 0 (
echo Please run this script as admin
:: Command to halt both this and the calling script
)
The goal would be for the parent script to not echo "I am still running" if the user running the parent script is not an admin. This is mainly to allow for easier maintenance, as instead of having to include the contents of admintest.bat in every script, you could just call it and quit as needed. Of course in this example admintest.bat has only a few lines of code, but the child script could be larger.