susja April 8, 2011 at 19:55:06 Specs: Windows XP SP3, 2Gb
Hello, I have a task: execute 2 commands: com1 and com2. I want that command com2 will be executed only if com1 succeeded. I use batch like this: @echo off set x=com1 %x% IF %ERRORLEVEL% NEQ 0 (EXIT) set y=com2 %y% The problem is that execution never get to line 'if' ... and check for condition. It looks that after %x% batch always exit and doesn't give the option to check for condition. Could someone give an idea how to prevent to terminate batch to exit after %x% and force to go to 'if' statement? Thanks in advance
I have no doubt that the problem is caused by com1. If my com1 is like set com1=copy x y then it works fine. But my actual com1 is a program and it looks like: set x=c:\myProgram\xyz %x% It looks that after execution com1 immediately exit and doesn't go to the next line. How to prevent it and force to go to the next line in my batch? thanks
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this
site. Computing.Net and Purch hereby disclaim all responsibility
and liability for the content of Computing.Net and its accuracy.