maxXPsoft Posted September 10, 2004 Share Posted September 10, 2004 Does anyone have a good method for catching error's in .cmd files and sending to a text file or pause it? As I've read there can be like 256 or so errorlevel'sThought I seen something here once before but can't find it for nothing. Link to comment Share on other sites More sharing options...
joshiieeii Posted September 22, 2004 Share Posted September 22, 2004 Hey maxXPsoft,I was wondering something similar when trying to troubleshoot a .cmd file the other day. The only thing I was able to find was that if you put a eg.">>C:\test.log" after every command that you execute, it will send the results to the example test.log. Example. "C:\dir>>C:\test.log" outputs what you would see if you ran that command in dos.I hope this is what you were asking about, and I hope it helps! Link to comment Share on other sites More sharing options...
jaclaz Posted September 23, 2004 Share Posted September 23, 2004 In NT4/2K/XP/2003 the latest ERRORLEVEL generated is stored by system in variable called, guess what?, ERRORLEVEL, so that to log them you just need something along the lines of:.....@ECHO OFFif exist %TEMP%\logfile.log del %TEMP%\logfile.logif not exist %TEMP%\logfile.log ECHO [Logfile start] > %TEMP%\logfile.log:doing_SOMETHINGDIR C:\ ::this ^ is the SOMETHING actionEcho DONE SOMETHING RESULTING ERRORLEVEL IS %ERRORLEVEL% >> %TEMP%\logfile.log......See here for more info and details:http://www.robvanderwoude.com/errorlevel.htmljaclaz Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now