Sign in to follow this  
Followers 0
thawee

Script won't wait with ProcessWaitClose

4 posts in this topic

$inst = ShellExecuteWait("C:\scripts\software\mb\program.exe"," /SP- /SILENT /NOCANCEL")

Errors(@error)
ProcessWaitClose("program.exe")
ProcessWaitClose("program.tmp")

Guictrlcreatelistviewitem (datetime() & "| Updating Database", $Reports)
$updt = ShellExecute("C:\Program Files\program\program.exe","/update")   <-------- Update Segment

Ok,

Here is the problem I am having. When I try to run the "update" segment of this code it fails saying that the program is already running and closes.

I don't understand why or how it could be running when i have the ProcessWaitclose making sure the process is in fact closed.

Putting a sleep command at 5 seconds seems to work, but it is not a clean way to solve this problem. I will be running this code on many different computers with different speeds, and the sleep may not always wait long enough.

I need to wait for the program to finish installing and exits before I run the updater portion of it.

Also I have watched the process table, and seen the processes close and then it open the updater. Is there a more effective way to determine a program is completely closed?

Is it possible that even though the process table is showing the program as closed its still in the process of closing down, and when the updater runs its noticing that it is still actively working on closing the install segment causing it to fail. Almost as if script is going so fast that its stumbles over its self?

Does anyone have any ideas on how to resolve this issues?

Thanks for your help!

:(

Share this post


Link to post
Share on other sites



I don't know what program it is nor do I know the parameters for that program but here is a hunch

The /NOCANCEL may be interfering with it.

Also, since you used ShellExecuteWait() there is really no need for the ProcessWaitClose("program.exe") since nothing is going to happen until the ShellExecuteWait() closes. And that should have been written as ProcessWaitClose($inst) anyway.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

And that should have been written as ProcessWaitClose($inst) anyway.

You're thinking about Run(), neither RunWait() nor ShellExecute() nor ShellExecuteWait() returns the PID.

ShellExecuteWait() "Success: Returns the exit code of the program that was run."

Maybe this will to the trick?

$iPID = Run("C:\scripts\software\mb\program.exe /SP- /SILENT /NOCANCEL","C:\scripts\software\mb\")
while ProcessExists($iPID)
    sleep(10)
wend

Guictrlcreatelistviewitem (datetime() & "| Updating Database", $Reports)

$iPID = Run("C:\scripts\software\mb\program.exe /update","C:\scripts\software\mb\")
while ProcessExists($iPID)
    sleep(10)
wend

Share this post


Link to post
Share on other sites

You're thinking about Run(), neither RunWait() nor ShellExecute() nor ShellExecuteWait() returns the PID.

ShellExecuteWait() "Success: Returns the exit code of the program that was run."

Maybe this will to the trick?

$iPID = Run("C:\scripts\software\mb\program.exe /SP- /SILENT /NOCANCEL","C:\scripts\software\mb\")
while ProcessExists($iPID)
    sleep(10)
wend

Guictrlcreatelistviewitem (datetime() & "| Updating Database", $Reports)

$iPID = Run("C:\scripts\software\mb\program.exe /update","C:\scripts\software\mb\")
while ProcessExists($iPID)
    sleep(10)
wend

thanks for all the help.

I am going to just put a sleep statement between the 2 applications.

I think its that the program is going to fast and stumbles over its self or its a glitch in windows where it doesn't completely close out the application before it takes it out of the process table.

either way thanks

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  
Followers 0