Vbscritp wait one process to finish and start another without Sleep

Asked

Viewed 43 times

1

I am with the following problem I rode a Vbscritp to automate some processes, I am using Sleep so that it waits for one process to finish to start another, but often the time is variable and it may take more or less than I defined, wanted it to be more automatic once it finished one process start another already identifying that the other ended, know if this is possible with VBS? If you don’t have any language that might be possible ? Thank you all

  • How do I know if it’s possible or not, without knowing which action/process to monitor to see if it’s over or not? Post the code.

1 answer

0

Use the "Run" method of the Shell Object, with the properties adjusted accordingly. See the code below:

CreateObject("Wscript.Shell").Run """C:\Program Files\ABC\abc.xex""", 0, True

The first argument is the path of the executable (or vbs script).

The secret is the third argument, if it is True, it will wait until the command is over and then continue to the next line, without using Sleep(), in practice a synchronous call. If you set to False, it already immediately continues running to next line, which is not what you want, in practice an asynchronous call.

The second argument is a number from 0 to 10, with the following intentions:

  1. Hide the window (and Activate Another window.)
  2. Activate and display the window. (Restore size and position) Specify this flag when Displaying a window for the first time.
  3. Activate & minimize.
  4. Activate & maximize.
  5. Restore. The active window remains active.
  6. Activate & Restore.
  7. Minimize & Activate the next top-level window in the Z order.
  8. Minimize. The active window remains active.
  9. Display the window in its Current state. The active window remains active.
  10. Restore & Activate. Specify this flag when Restoring a minimized window.
  11. Sets the show-state based on the state of the program that Started the application.

Jahwakening!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.