File_WaitForFileToExist
VB Scripting Library > OSD Scripting Library > File functions (OSD)
File_WaitForFileToExist(sFile, iWaitMaxMin, iCheckIntervalSec, bMustExist)
Section titled “File_WaitForFileToExist(sFile, iWaitMaxMin, iCheckIntervalSec, bMustExist)”Checks if a specified file exists, and waits until the file exists or until a timeout occurs.
If the file exists, or is created before the timeout occurs, gbValue returns TRUE, otherwise gbValue returns FALSE.
giValue returns the number of seconds the function waited.
Arguments
Section titled “Arguments”| ARGUMENT | DESCRIPTION | TYPE |
|---|---|---|
| sFile | The file to check existence/wait for | String |
| iWaitMaxMin | Number of minutes to wait for the file to be created before exiting | Integer |
| iCheckIntervalSec | Number of seconds between checks | Integer |
| bMustExist | If TRUE, the function fails if the timeout is reached and the file doesn’t exist | Boolean |
Return Type
Section titled “Return Type”Boolean, TRUE if function completed successfully.
If bMustExist is TRUE and the file doesn’t exist when the timeout is reached, the function returns FALSE.
Example
Section titled “Example”The following example will wait for up to 5 minutes for an external process to create a file, and check for the file every 10 seconds.
Private Function IncludeScript(sScriptFile) '...End Function
'Begin bStatus=True If bStatus Then bStatus=IncludeScript("customlib.cis") If bStatus Then bStatus=IncludeLibrary("Capalib.cin") If bStatus Then bStatus=IncludeLibrary("Osdlib.cin") If bStatus Then bStatus=Job_Start("WS", "Script Name", "1.0", "ScriptName.log", "INSTALL") If bStatus Then bStatus=OSD_Initialize()
sFile="C:\WaitFile.txt"
If bStatus Then bStatus=File_WaitForFileToExist(sFile, 5, 10, False) If bStatus and NOT gbValue Then bStatus=Dialog_ShowWarning("Timeout occured waiting for file to be created")
Job_End(bStatus)'End mainSee Also
Section titled “See Also”Scripting Guidelines, Dialog_ShowWarning Constants Package Property Variables