Reputation: 3794
I'm trying to script the shutdown of my VM Servers in a .bat. if one of the vmware-cmd commands fails (as the machine is already shutdown say), I'd like it to continue instead of bombing out.
c:
cd "c:\Program Files\VMWare\VmWare Server"
vmware-cmd C:\VMImages\TCVMDEVSQL01\TCVMDEVSQL01.vmx suspend soft -q
vmware-cmd C:\VMImages\DevEnv\DevEnv\DevEnv.vmx suspend soft -q
vmware-cmd C:\VMImages\DevEnv\TCVMDEV02\TCVMDEV02.vmx suspend soft =q
robocopy c:\vmimages\ \\tcedilacie1tb\VMShare\DevEnvironmentBackups\ /mir /z /r:0 /w:0
vmware-cmd C:\VMImages\TCVMDEVSQL01\TCVMDEVSQL01.vmx start
vmware-cmd C:\VMImages\DevEnv\DevEnv\DevEnv.vmx start
vmware-cmd C:\VMImages\DevEnv\TCVMDEV02\TCVMDEV02.vmx start
Upvotes: 20
Views: 51802
Reputation: 22404
If you are calling another batch file, you must use CALL batchfile.cmd
Upvotes: 7
Reputation: 6764
A batch file should continue executing, even if the previous command has generated an error. Perhaps, what you are seeying is the batch aborting due to some other error?
Upvotes: 0
Reputation: 61568
Run it inside another command instance with CMD /C
CMD /C vmware-cmd C:\...
This should keep the original BAT files running.
Upvotes: 33
Reputation: 14738
You could write a little Program that executes the command an returns a value (say -1 for an error). This value can then be used in your Batch-File.
Upvotes: 0
Reputation: 655
Have you tried using "start (cmd)" for each command you are executing?
Upvotes: 4