corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Batch file writing


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Batch file writing
jamesw
Member

Registered: 28th Jun 02
Location: Station Town, County Durham
User status: Offline
7th Mar 08 at 19:27   View User's Profile U2U Member Reply With Quote

Ive got a big ass batch file I nocked up to use at work - basically just a menu system that uses varibles to launch different commands and run different fixes, my question is what on earth is the difference between using "errorlevel" and the varible %errorlevel% - i thought they were the same?! obviously not

Example

find supposed to give exit code 0 if it finds a match, and exit code 1 if the search runs but it cant find a match - but try the below it dont work out

echo completed | find "failed"
if errorlevel 0 echo match found

the above for some reason will trigger the errorlevel 0 command
so why on earth is it picking up errorlevel 0???

where as the below works fine as expected

echo completed | find "failed"
if %errorlevel%==0 echo match found

Its not a problem, i can just use the varible, just curious

[Edited on 07-03-2008 by jamesw]

[Edited on 07-03-2008 by jamesw]
jamesw
Member

Registered: 28th Jun 02
Location: Station Town, County Durham
User status: Offline
7th Mar 08 at 19:31   View User's Profile U2U Member Reply With Quote

Found my answer

ERRORLEVEL nnn (v2.0 Win95 NT3.1)
Specifies a true condition only if the previous program run by COMMAND.COM returned an exit code equal to or greater than number.
ERRORLEVEL statements must listed in DECREASING order. The operating system will consider the IF statement true if the ERRORLEVEL is greater than or equal to the values specified, see the CHOICE examples.
Normal completion of a command will return ERRORLEVEL=0.

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Batch file writing Skinz Geek Day 3 723
6th Jul 05 at 11:32
by loafofbrett
 
Autorun/Commands Dan Lewis Geek Day 2 430
20th Oct 06 at 13:18
by almost_me
 
Need to convert a batch file into VBScript Richie Geek Day 6 600
18th Oct 07 at 23:05
by Richie
 
Batch File help Dan Lewis Geek Day 6 246
23rd Nov 07 at 09:40
by Dan Lewis
 
Remotely locking screens/kboards/mice of computers by a teacher in one room? pow Geek Day 48 589
11th Dec 07 at 17:30
by pow
 

Corsa Sport » Message Board » Off Day » Geek Day » Batch file writing 28 database queries in 0.5107150 seconds