Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Help with error levels
Name: amlife Date: October 22, 2008 at 06:40:17 Pacific OS: OS XP CPU/Ram: 2GB Product: DELL
Comment:
Hello guys I just want to know if what I'm doing works! I have bunch of code gets executed line by line.
ex. IF EXIST C:\filename.txt DEL C:\filename.txt if errorlevel 1 echo File has been deleted.
however if I have tens of lines. will I need to specify error levels for each line. error level 1 for one and error level 2 for second line .. etc ???
Name: IVO Date: October 22, 2008 at 07:26:36 Pacific
Reply:
Under Windows NT/2K/XP you can code
if %ErrorLevel% equ # <your command>
type if /? to know about other relational operators (e.g. gtr, lss and so on)
0
Response Number 2
Name: IVO Date: October 22, 2008 at 07:35:14 Pacific
Reply:
Sorry,
I did not understand your question, so now I hope to give you the right response.
The ErrorLevel is not bound to the line position, it is set by the latest command executed. So if you want to check for a failed action you have to code always
if ErrorLevel 1
no matter how many times. Keep in mind if ErrorLevel is satisfied for return codes equal or greater than the value indicated.
0
Response Number 3
Name: Mechanix2Go Date: October 22, 2008 at 09:06:30 Pacific
Reply:
"IF EXIST C:\filename.txt DEL C:\filename.txt"
will return 0 regardless
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 4
Name: amlife Date: October 22, 2008 at 17:10:11 Pacific
Summary: i was trying to write a batch file that installs a program, and when there is an error return the error level - except when it has errorlevel 3010 @echo off :SP2 Start /wait C:\SQLInstall\SP2\SQLServe...
Summary: Hi Guys, I need a wee bit of help with a project I am working on. Part of it involves writing a Modulus 11 check which is causing me no end of trouble. I have made several attempts at trying to write ...
Summary: Hi, I was wandering if anybody here could help me out with a programming assigment i have to do. I'm not asking for the total solution, I really want to learn this stuff, but i need some help with ...