# File_WaitWhileExist

> Checks if a specified file exists, and waits while the file exists or until a timeout occurs.

Source: https://docs.capaone.com/capainstaller/vb-scripting-library/osd-scripting-library/file-functions-osd/file-waitwhileexist/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

[VB Scripting Library](/capainstaller/vb-scripting-library/) > [OSD Scripting Library](/capainstaller/vb-scripting-library/osd-scripting-library/) > [File functions (OSD)](/capainstaller/vb-scripting-library/osd-scripting-library/file-functions-osd/)

### File_WaitWhileExist(sFile,iWaitMaxMin,iCheckIntervalSec)

Checks if a specified file exists, and waits while the file exists or until a timeout occurs.  
If the file is deleted before the timeout occurs, gbValue returns TRUE, otherwise gbValue returns FALSE.

### Arguments

| ARGUMENT          | DESCRIPTION                                                         | TYPE    |
|:------------------|:--------------------------------------------------------------------|:--------|
| sFile             | The file to check existence/wait for                                | String  |
| iWaitMaxMin       | Number of minutes to wait for the file to be deleted before exiting | Integer |
| iCheckIntervalSec | Number of seconds between checks                                    | Integer |

### Return Type

Boolean, TRUE if function completed successfully.

### Remarks

### Example

The following example will create an empty text file and wait for up to 5 minutes for an external process to delete it.

**VBScript**

```vb
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_CreateEmptyFile(sFile, False)
  If bStatus Then bStatus=File_WaitWhileExist(sFile,5,10)
  If bStatus and NOT gbValue Then = Dialog_ShowWarning("Timeout occured waiting for file to be deleted")

  Job_End(bStatus)
'End main

```

### See Also

[Scripting Guidelines](/capainstaller/vb-scripting-library/scripting-guidelines/), [Dialog_ShowWarning](/capainstaller/vb-scripting-library/osd-scripting-library/dialog-functions-osd/dialog-showwarning/) [Constants](/capainstaller/vb-scripting-library/addendum/constants/) [Package Property](/capainstaller/vb-scripting-library/addendum/package-property/) [Variables](/capainstaller/vb-scripting-library/addendum/variables/)
