DarkBoost Posted January 17, 2009 Share Posted January 17, 2009 (edited) I have written a script to automate a program installation and as it completes it automatically starts the application, there are no command switches to avoid this. I need to stop the process and delete the file to apply the needed update however after the process is closed the file will not delete even if sleeping 1min before running the delete. Any ideas? ;example script only... $dir = "c:\winzip\" $exe = "winzip.exe" If ProcessExists($exe, 5) Then ProcessClose($exe) ProcessWaitClose($exe) EndIf While 1 If FileExists($dir & $exe) Then FileDelete($dir & $exe) Else ExitLoop EndIf WEnd In addition I have tried the following: -> Sleep(10000) before running FileDelete -> End Explorer.exe process and then run the FileDelete -> FileClose($dir & $exe) then FileDelete Not sure what else to try? Edited January 17, 2009 by DarkBoost Link to comment Share on other sites More sharing options...
TerarinK Posted January 17, 2009 Share Posted January 17, 2009 First I would like to know why the 5 is in there with the ProcessExists? Secondly why delete the winzip.exe but leave the whole thing still (WinZip) there? 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E Link to comment Share on other sites More sharing options...
DarkBoost Posted January 17, 2009 Author Share Posted January 17, 2009 Was confused with ProcessWait Maybe this will help? I am trying to ProcessClose("A") and then FileDelete("A") but unable to because it appears the file/process is still running even after being closed. Link to comment Share on other sites More sharing options...
TerarinK Posted January 17, 2009 Share Posted January 17, 2009 (edited) ;example script only... $dir = "c:\winzip\" $exe = "winzip.exe" While 1 If WinExists($dir & $exe) Then If WinClose($exe) Then FileDelete($dir & $exe) Else ExitLoop EndIf WEnd Edited January 17, 2009 by TerarinK 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E Link to comment Share on other sites More sharing options...
DarkBoost Posted January 17, 2009 Author Share Posted January 17, 2009 Trying this now. I always thought the closing the process was a more powerful function than closing the window? Link to comment Share on other sites More sharing options...
GEOSoft Posted January 17, 2009 Share Posted January 17, 2009 You might also want to compare your If ProcessExists($exe, 5) Then to the help file for the ProcessExists() function 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...
DarkBoost Posted January 17, 2009 Author Share Posted January 17, 2009 GEOSoft as mentioned before i was confused with ProcessWait Link to comment Share on other sites More sharing options...
FireFox Posted January 17, 2009 Share Posted January 17, 2009 @DarkBoost $wgp = WinGetProcess("winrar") $pgp = _ProcessGetPath($wgp) While FileExists($pgp) ProcessClose($wgp) FileDelete($pgp) WEnd Cheers, FireFox. 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