Jump to content

Wait till file exists then delete it


Recommended Posts

Hey,

Is there a way to tell a script to wait till a particular file and directory exists before deleting it? The following works to a degree:

;;Delete Icon from User's Desktop and Start Menu
WinWaitClose("InstallShield Wizard", "", 20)
FileDelete($UPD)
DirRemove($UPSM,1)
MsgBox(0, "Finished", "Please restart the computer to complete the installation")

The directory and icons in question are created as part of a installation program that this script runs earlier. There are times though due to computer speed, network activity where there can be a delay before the icons appear (longer than 20 seconds) and in these cases the script does not wait.

Is there a better command than WinWaitClose to use in this scenario?

Sutefan

これは私の署名であり, 私の名前はsutefan である !

Link to comment
Share on other sites

I use a For Next loop, to wait for shortcut creation etc. in install scripts. Then you can wait, but are not stuck in an endless loop either.

For $i = 1 To 20; Adjust count if needed.
    If FileExists('Your file here') Then ExitLoop
    Sleep(250); Adjust time if needed.
Next

This will halt the script, until the FileExists, or til the loop count reaches 20.

:)

Link to comment
Share on other sites

Hey,

Is there a way to tell a script to wait till a particular file and directory exists before deleting it?  The following works to a degree:

;;Delete Icon from User's Desktop and Start Menu
WinWaitClose("InstallShield Wizard", "", 20)
FileDelete($UPD)
DirRemove($UPSM,1)
MsgBox(0, "Finished", "Please restart the computer to complete the installation")

The directory and icons in question are created as part of a installation program that this  script runs earlier.  There are times though due to computer speed, network activity where there can be a delay before the icons appear (longer than 20 seconds) and in these cases the script does not wait.

Is there a better command than WinWaitClose to use in this scenario?

Sutefan

<{POST_SNAPBACK}>

Why don't you just increase the timeout?

WinWaitClose("InstallShield Wizard", "", 60)

EDIT: Unless you are saying that the delay is happening after the InstallShield Wizard window has closed.

Edited by SumTingWong
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...