Jump to content
Sign in to follow this  
KickStarter15

Pause the script until ShellExecute is finished

Recommended Posts

KickStarter15

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.

Share this post


Link to post
Share on other sites
AutoBert

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.

  • Thanks 1

Share this post


Link to post
Share on other sites
KickStarter15

Thanks @AutoBert. ^_^ it's working. However, i switch the $sPid1 and $sPid2 to work. Thanks!


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.

Share this post


Link to post
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
Sign in to follow this  

×