RayOK Posted December 8, 2005 Share Posted December 8, 2005 In my unattended .cmds I want to be able to log both the success and errors to one log file. With a little testing I can output success or errors but not both in one file.. How would do I output everything to one file? This is about what I have so far.. (the extent of my cmd/batch scripting knowledge )(echo.:: would also like to stick the next 3 lines on one line but not importantecho Setup Log FileDate /tTime /techo.echo Copying somefile..copy somefile.txt somefile2.txtecho.echo Deleting that file, just testing..del somefile2.txtecho.:: should log an error but does not.. help!echo Deleting a file that doesn't exist to testdel nosuchfile.txtecho.) > log.txtThanks for any help Link to comment Share on other sites More sharing options...
John McGuire Posted December 9, 2005 Share Posted December 9, 2005 (edited) You need to trap the error levelAdd "echo %errorlevel%" to your script to output the error level, in this case 0IF ERRORLEVEL=0 goto errgoto :eof:errecho error2 Edited December 9, 2005 by John McGuire Link to comment Share on other sites More sharing options...
Yzöwl Posted December 12, 2005 Share Posted December 12, 2005 Trysome command >output.txt 2>&1 Link to comment Share on other sites More sharing options...
RayOK Posted December 12, 2005 Author Share Posted December 12, 2005 Ahh thanks Yzöwl! That works perfectly. Don't have to change anything but add a few characters to the end. Where is all this stuff documented anyway? I searched for a while and didn't find much info about advanced topics like this. Any good sites you know of?John McGuire, I tried yours too but it was too much work for my lengthy script. I would have to do the if errorlevel thing for almost every command. Don't even think it outputted the error to the same file in the correct location. Still, more than I thought of. Thanks tho. 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