Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Help with Condition / Script

Created: 16 Aug 2013 • Updated: 19 Aug 2013 | 2 comments
This issue has been solved. See solution.

Not much of a scripter so dont know where i'm going wrong here.

I have a job that will determine the chassis type(this will let me run certain laptop jobs)

this is the batch file called get chassis type.

for /f "delims={}" %%i in ('"wmic systemenclosure get chassistypes | find "{""') do set chassisType=%%i
EXIT /B %chassisType%

If i run this file on the machine and output to screen the value is 3

If I do a condition job it fails!

What am i doing wrong..... apart from working in I.T. :-)

 

Capture12_1.PNG

Operating Systems:

Comments 2 CommentsJump to latest comment

rmasters's picture

Easy fix. Remove the "/B" from your EXIT command, then it will work as intended.

 

For more explanation on why check out the exit's help command.  When you use /B and the exitCode together the Exit code is always 0 and the ERRORLEVEL is equal to what the exitCode is specified as.

>exit /?
Quits the CMD.EXE program (command interpreter) or the current batch
script.

EXIT [/B] [exitCode]

  /B          specifies to exit the current batch script instead of
              CMD.EXE.  If executed from outside a batch script, it
              will quit CMD.EXE

  exitCode    specifies a numeric number.  if /B is specified, sets
              ERRORLEVEL that number.  If quitting CMD.EXE, sets the process
              exit code with that number.

Normally /B is used when child batch file is called by the parent.  In that situation if you don't use /B in the child, it will close the parent.

SOLUTION