MSFN Forum: cmd file help error - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

cmd file help error Rate Topic: -----

#1 User is offline   maxXPsoft 

  • MSFN Master
  • Group: Developers
  • Posts: 2,482
  • Joined: 14-November 03
  • OS:Windows 7 x64
  • Country: Country Flag

  Posted 09 September 2004 - 07:43 PM

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's

Thought I seen something here once before but can't find it for nothing.


#2 User is offline   joshiieeii 

  • Newbie
  • Group: Members
  • Posts: 39
  • Joined: 14-September 04

Posted 22 September 2004 - 01:37 PM

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:

#3 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 8,792
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 23 September 2004 - 03:56 AM

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.robvander...errorlevel.html

jaclaz

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy