@echo off
rem
rem AutoRun (Startup Group for BartPE & Nu2Menu)
rem Copyright (c) 2003-2004 Erwin Veermans (http://www.veder.com/nwdskpe/)
rem

if not exist %SystemRoot%\System32\Keydown.exe goto _default
rem Disable all AutoRun by Toggling Scroll-Lock and Num-Lock and Caps-Lock ON
%SystemRoot%\System32\Keydown.exe 145 144 20
if errorlevel 1 goto _end
rem Confirm each AutoRun by toggling Scroll-Lock ON (Debug Mode)
%SystemRoot%\System32\Keydown.exe 145
if errorlevel 1 goto _debug
goto _default

:_debug
if not exist %SystemRoot%\System32\debugrun.cmd goto _end
start "Scroll-Lock detected: Entering Debug Mode" "%SystemRoot%\System32\debugrun.cmd"
goto _end

:_default
rem First Group, Pre-Default Group  
for %%i in (%SystemRoot%\System32\autorun1*.cmd %SystemRoot%\System32\autorun2*.cmd) do start "%%i" /wait /min "%%i"
rem Default Group, Post-Default Group
for %%i in (%SystemRoot%\System32\autorun_*.cmd %SystemRoot%\System32\autorun9*.cmd) do start "%%i" /wait /min "%%i"
rem Post Default Concurrent Group (no /wait)
for %%i in (%SystemRoot%\System32\autorun0*.cmd) do start "%%i" /min "%%i"
:_end
