Hi there...
I have this code to set Folder attributes, but I have not done a lot with FUNCTIONS. I want this to popup a YES or NO for the user to run it or not. I am not sure if Select Case is the way to go or if there is a better way to write this script. I have had several versions so far. Any help is a great learning experience for me.
I have this code to set Folder attributes, but I have not done a lot with FUNCTIONS. I want this to popup a YES or NO for the user to run it or not. I am not sure if Select Case is the way to go or if there is a better way to write this script. I have had several versions so far. Any help is a great learning experience for me.
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("Wscript.Shell")
Dim Msg
sCurrentDirectory = WSHShell.CurrentDirectory & "\"
notEmpty(sCurrentDirectory)
Msg = MsgBox("This script should be run in the directory you want to Hide/Unhide folders for." & vbcr & vbcr & _
"Do you want to run the script now" ,vbYesNo,"Path: " & sCurrentDirectory )
s = Timer
f= -1
'WScript.Echo("Completed " & f & " folders for " & Timer - s & " seconds")
Function notEmpty(setFolder)
On Error Resume Next
Select Case Msg
Case vbYes
f = f +1
Set objFolder = objFSO.GetFolder(setFolder)
attr = 2 '' hidden
if objFolder.Files.Count > 0 then attr = 0
subattr = 2
for each objSubfolder in objFolder.SubFolders
subattr = notEmpty(objSubfolder.Path)
if subattr = 0 then attr = 0
next
objFolder.Attributes = attr
notEmpty=attr
Case vbNo
WScript.Quit
End Select
End Function