I can use ERRORLEVEL, but tried and with a loop it failed. I am writing a batch "shell." Since I have tried and tried, I am finally asking for help. The reason I don't want to use errorlevel is because the loop.
(FULL) SHELL
@set /p build=<"C:\Users\%username%\Desktop\WellOS2\WellOS\Build".txt @title WellOS V.%build% @echo off goto boot :register cls echo You are registering... echo If this is an error press CTRL + C NOW... pause cls set /p user= Enter your username: set /p passwordreg= Enter your password: mkdir "C:\Users\%username%\Desktop\WellOS2\Users\%user%" mkdir "C:\Users\%username%\Desktop\WellOS2\Users\%user%\Documents" echo %passwordreg% >"C:\Users\%username%\Desktop\WellOS2\Users\%user%\password".txt echo 2 >"C:\Users\%username%\Desktop\WellOS2\OSfiles\bootset".txt echo Your done. pause goto welloslog :booterror echo Sorry the boot file has an error. Check the user manual for BOOT$ pause :boot set /p boot=<"C:\Users\%username%\Desktop\WellOS2\OSfiles\bootset".txt if %boot% == 1 goto register if %boot% == 2 goto welloslog goto booterror cls :ERROR cls echo ----------ERROR------------------- echo %error% pause goto %back% :welloslog cls echo Welcome to WellOS2! echo ----------------LOGIN------------- set /p user= Username: if exist "C:\Users\%username%\Desktop\WellOS2\Users\%user%" goto pass set error= Sorry that account doesn't exist. set back=welloslog goto welloslogerror :pass set /p password=<"C:\Users\%username%\Desktop\WellOS2\Users\%user%\password".txt set /p passwordlog= Password: if /i %passwordlog% == %password% goto wellos set error= Sorry! wrong password. set back= welloslog goto error :wellos cls :wellosnocls echo --------------MAIN--------------- echo type help for help set /p command= #: if exist "C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.sys" set type=sys if exist "C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.pro" set type=pro if exist "C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.sys" goto po if exist "C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.pro" goto po set error= !Unreconized program/system program! set back=wellos goto error :po set lines=0 echo --------------%command%.%type%--------------- :porep set /a lines=%lines% + 1 set /p "code="<"C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.%type%\%command%.%type%-%lines%".wellcode if "%code%"=="GOWELL" goto wellosnocls findstr /I /L "if" "C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.%type%\%command%.%type%-%lines%.wellcode" :skip call %code% goto porep ::Tools :iftl %code% goto porep PROGRAM OPENER (What I am talking about, and having problems with...)
:po set lines=0 echo --------------%command%.%type%--------------- :porep set /a lines=%lines% + 1 set /p "code="<"C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.%type%\%command%.%type%-%lines%".wellcode if "%code%"=="GOWELL" goto wellosnocls findstr /I /L "if" "C:\Users\%username%\Desktop\WellOS2\Programdata\%command%.%type%\%command%.%type%-%lines%.wellcode" goto iftl :skip call %code% goto porep ::Tools :iftl %code% goto porep
ErrorLevelnot be possible?find/findstr(re-)set it if a/no match is found, so whan querying immediately afterwards, it will give the result; if you queryErrorLevelin a loop/block, use delayed expansion and use!ErrorLevel!rather than%ErrorLevel%... alternatively check whether or not the output offind/findstris (not) empty, by parsing it withfor /F, for instance...ERRORLEVEL, even if it just sets it to 0 to indicate success. If you must preserve it, then your best bet is to save it to a variable, run your commands, and then restore it. See stackoverflow.com/questions/6498460/…%errorlevel%inside of a loop when you should have been using!errorlevel!.findstr /I /L "if" "C:\*\*.wellcode" goto iftlin the program opener, you want to dogoto iftlin case a match is found? if so, just place&&beforegoto iftl; see also my updated answer...