Jump to content

Pause the script until ShellExecute is finished


Recommended Posts

Hi Experts,

I've got a small issue right now about opening a file .log and .xml where I need to pause first the script up until these two files were closed.

ShellExecute(@ScriptDir & "\Log\Validator.log")
    Sleep(2000)
    ShellExecute(@ScriptDir & "\Sample.xml") ; pause the script here until this xml will close.

I tried "WinWait()" and "WinWaitActive()" but the script will continue after few seconds declared and if I won't add the second to display, the script won't continue.

Any idea how to handle this Experts?:sweating:

 

Thanks in advance.

KS15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

Seems to be easy. Just check the 2 pid's: ShellExecute return's a Pid for each process you start, so just loop until both ended.

 

So this:

$sPid1 = ShellExecute(@ScriptDir & "\Log\Validator.log")
    Sleep(2000)
$sPid2 = ShellExecute(@ScriptDir & "\Sample.xml") ; pause the script here until this xml will close.
$bOK =False
Do
    $bOK = Not ProcessExists($pid1)
    If $bOK Then $bOK = Not ProcessExists($pid2)
    sleep(100)
Until $bOK

should do your job.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...