Jump to content

ProcessClose then FileDelete => Fails


Recommended Posts

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 by DarkBoost
Link to comment
Share on other sites

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

;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 by TerarinK

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

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

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...