25

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"

user66001
  • 774
  • 1
  • 13
  • 36
yael
  • 2,765
  • 10
  • 40
  • 48

1 Answers1

39

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()
Our Man in Bananas
  • 5,809
  • 21
  • 91
  • 148
Sarfraz
  • 377,238
  • 77
  • 533
  • 578