Hide a Folder Only if it's not Hidden Already

G

Guest

I'm using the following VBS to hide/unhide a folder:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\FSO")

If objFolder.Attributes = objFolder.Attributes AND 2 Then
objFolder.Attributes = objFolder.Attributes XOR 2
End If

My question is how do I get the script to only run if the folder is not
hidden (i.e. the folder is already set to HIDDEN and I don't want to unhide
it)? When I run the script in succession it hides/unhides each time. I want
the script to only hide the folder if it is not already hidden. Also, I
would like all subdirectories and files to be hidden as well if they are not
already. Any help would be greatly appreciated. Please be patient with me
as I am totally new at this VBS thing. I'll try to not be too much of a pain.
 
A

Ayush

[Donald Fisher] wrote-:
would like all subdirectories and files to be hidden as well if they are not
already.

Use the attrib command :
attrib +h /s /d c:\fso


Good Luck, Ayush.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top