Prevent Accidental Start of a Batch File

To prevent accidental start of a batch file (e.g. restarting services or a starting load), you can add the following lines in the beginning.

  • Use Y as a first argument when scheduling the file
  • You will be prompted to answer whether you want to continue, if you start the batch.
@echo off
if /I "%1"=="Y" goto start
set /p continue="Continue (Y/N): "
if /I "%continue%"=="Y" goto start
exit /b
:start

rem ... your script ... 
echo test

prevent start