The autorun batch file is basically just a few commands that run on startup of the command window (in order to configure that session). However, I also have a "Choice" section of code in there, and I would like that section of code to run only when a certain Doskey macro is typed in, but not at any other time.
I've tried various options to have that section of code skipped until it is invoked by a designated macro, but it still runs at startup every time.
What would be the best way to achieve this?
Below is the autorun batch file that I'm testing. All attempts to constrain the choice code have been removed from it (because none of them worked, and they were a mess).
Thanks!
Code: Select all
@ECHO Off
TITLE SUPER USER
CD C:\Windows
Color 4F
@whoami /user /FO list
set prompt=[Root] $p$g
:choice
echo.
echo.
::define a variable containing a single backspace character (to allow spaces to display at beginning of line)
for /f %%A in ('"prompt $H &echo on &for %%B in (1) do rem"') do set BS=%%A
set /p c=%BS% Start a new command session? [Y/N]
if /I "%c%" EQU "Y" goto :proceed
if /I "%c%" EQU "N" goto :notproceed
goto :choice
:proceed
cmd /E:ON /k c:\su.cmd
goto :end
:notproceed
@echo.
@echo.
goto :end
:end