Wait for cmd.exe to finish

Hi

how can i have the process wait effectively until a batch file run under cmd.exe ( and opening the cmd exe screen ) is closed?

I tried the VBO under environment but somehow it doesnt stop it from running the script directly to the end.

Many thanks! Ralph
 
Hi somehow it doesn't seem to pick that up.. Does it require to type the whole path of cmd or a specific action to recognize the open program? Many thx Ralph
 

ivan.gordeyev

New Member
Use the 'Process Exists' action under 'Utility - General' Object to find if the process is running.

Also you can try to attach, if attach successful, then detach and wait 1 second and attach again. When attach fails or when you exceed number of attempts, you can switch off CMD.
 

sivagelli

Well-Known Member
cmd.exe closes once the batch is executed, IF there is no 'pause' statement at the end of the batch file.

You may use 'Start Process' action from Environment VBO and kick-off the batch passing the full path of cmd.exe and batch file as argument.
Application: "C:/windows/System32/cmd.exe"
Arguments: "/c <Path of the Batch file>"

Add a 'Wait for Process' action from Environment VBO specifying the maximum wait time in seconds and pass the Process Name as "cmd". The output is a flag.

The only difference between the @ivan.gordeyev suggestion of using 'Process Exists' and using the 'Wait for Process' is - you have to specify wait time before calling 'Process Exists' action, whereas you can specify the wait time in the 'Wait for Process' action itself. Other than that, both work similarly. But, you can save memory as the object 'Environment' is already loaded in to memory when you use 'Start Process'.

Post back your comments.
 
Last edited:
Hi Thanks for all info,
utlimately only one thing was bugging the process- which was a missing line in ATTACH element cmd.exe , windows Title "C:\windows\system32\cmd.exe"

Many thanks for your valuable input !Ralph
 
Top