Link to home
Start Free TrialLog in
Avatar of Vicki05
Vicki05Flag for United States of America

asked on

Verify if one of the folders exist

Hi All,

I am trying to find out how can I check to see if one of the two folders exists. If it does then proceed to the next step. If both of the folders are not there, then it errors out. Please advice.


Set objFSO = CreateObject("Scripting.FileSystemObject")
            If objFSO.FolderExists "C:\Program Files\Test\DatabaseON" or "C:\Program Files\Test\DatabaseOFF" Then
            run program
            End If
Else
MsgBox "Database Error"
            Wscript.Quit
SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vicki05

ASKER

How can I use this if I want to first check folder does not exist to error out to error out else run the script?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
as per theabove script if any of the foler exists it will run the script else it will error meesage
Sorry that would be slightly different:

Set objFSO = CreateObject("Scripting.FileSystemObject") 
            If (objFSO.FolderExists("C:\Program Files\Test\DatabaseON") and objFSO.FolderExists("C:\Program Files\Test\DatabaseOFF")) Then
            run program
            End If
Else
MsgBox "Database Error"
            Wscript.Quit

Open in new window


Didn't need the not ... I originally thought about a slightly different approach!

Chris
Avatar of Vicki05

ASKER

Thanks for the help. It got me in the right direction