[vbscript] How to Verify if file exist with VB script

How do I verify via VBScript if the file conf exist under Program Files (i.e. C:\Program Files\conf)?

For example if it exists, then msgBox "File exists"
If not, then msgbox "File doesn't exist"

This question is related to vbscript

The answer is


There is no built-in functionality in VBS for that, however, you can use the FileSystemObject FileExists function for that :

Option Explicit
DIM fso    
Set fso = CreateObject("Scripting.FileSystemObject")

If (fso.FileExists("C:\Program Files\conf")) Then
  WScript.Echo("File exists!")
  WScript.Quit()
Else
  WScript.Echo("File does not exist!")
End If

WScript.Quit()