Sign in to follow this  
Followers 0
DarkBoost

ProcessClose then FileDelete => Fails

8 posts in this topic

#1 ·  Posted (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 by DarkBoost

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by TerarinK

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites

Trying this now. I always thought the closing the process was a more powerful function than closing the window?

Share this post


Link to post
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!"

Share this post


Link to post
Share on other sites
GEOSoft as mentioned before i was confused with ProcessWait

Share this post


Link to post
Share on other sites

@DarkBoost

$wgp = WinGetProcess("winrar")
$pgp = _ProcessGetPath($wgp)
While FileExists($pgp)
ProcessClose($wgp)
FileDelete($pgp)
WEnd

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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