I'm trying to use an IF statement with %ERRORLEVEL% to ECHO into a text document that it fails. However, I call another batch file at the top to reference credentials so that I can log onto the remote computer. The batch file thinks %ERRORLEVEL% is a variable in that batch file I called at the top and as a result enters a blank variable in place of %ERRORLEVEL%. Is there a better way to go about this?
call "D:\TEST\CREDS.bat"
net use \\2100\D$ %NETPSWRD% /USER:%WINUSER% /PERSISTENT:NO
IF %ERRORLEVEL% NEQ 0 ECHO 2100>>D:\LOGS\Failed.txt