Jump to content

cmd file help error


Recommended Posts

  • 2 weeks later...

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! :hello:

Link to comment
Share on other sites

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 OFF
if exist %TEMP%\logfile.log del %TEMP%\logfile.log
if not exist %TEMP%\logfile.log ECHO [Logfile start] > %TEMP%\logfile.log

:doing_SOMETHING
DIR C:\
::this ^ is the SOMETHING action
Echo DONE SOMETHING RESULTING ERRORLEVEL IS  %ERRORLEVEL% >> %TEMP%\logfile.log
......

See here for more info and details:

http://www.robvanderwoude.com/errorlevel.html

jaclaz

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...