thawee Posted April 7, 2010 Share Posted April 7, 2010 $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! Link to comment Share on other sites More sharing options...
GEOSoft Posted April 7, 2010 Share Posted April 7, 2010 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!" Link to comment Share on other sites More sharing options...
KaFu Posted April 7, 2010 Share Posted April 7, 2010 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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
thawee Posted April 8, 2010 Author Share Posted April 8, 2010 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now