I have a script that is mostly working to enumerate and list (in a text file) all the subfolders on a drive. PROBLEM -- it halts when it gets to the "System Volume Information" folder. "Permission Denied" is the error. I've tried to write the script so that it will skip this folder, but it still stops there every time.
Here is the script. Any idea how to fix this problem? Thanks!
***************************************************
Set oShell = WScript.CreateObject ("WSCript.shell"
Const ForAppending = 2
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objTextFile = objFSO.OpenTextFile _
("c:\Windowsscripts\Folderlist.txt", ForAppending, True)
Set FSO = CreateObject("Scripting.FileSystemObject"
sDIR = "\\SERVER\e$"
SET objDIR = GetFolder(sDIR)
GoSubFolders objDIR
Sub GoSubFolders (objDIR)
If objDIR <> "\System Volume Information" Then
for each eFolder in objDIR.Subfolders
objTextFile.WriteLine(efolder.Path)
GoSubFolders eFolder
Next
End If
End Sub
Function GetFolder(sFOLDER)
On Error Resume Next
Set GetFolder = FSO.GetFolder(sFolder)
If Err.Number <> 0 Then
WScript.Echo "Error connecting to folder: " & sFolder &_
VBlf & "[" & Err.Number & "] " & Err.Description
Wscript.Quit Err.Number
End If
End FUnction
objTextFile.Close
oShell.Popup "Process Complete", 6, strTitle, vbInformation
Here is the script. Any idea how to fix this problem? Thanks!
***************************************************
Set oShell = WScript.CreateObject ("WSCript.shell"
Const ForAppending = 2
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objTextFile = objFSO.OpenTextFile _
("c:\Windowsscripts\Folderlist.txt", ForAppending, True)
Set FSO = CreateObject("Scripting.FileSystemObject"
sDIR = "\\SERVER\e$"
SET objDIR = GetFolder(sDIR)
GoSubFolders objDIR
Sub GoSubFolders (objDIR)
If objDIR <> "\System Volume Information" Then
for each eFolder in objDIR.Subfolders
objTextFile.WriteLine(efolder.Path)
GoSubFolders eFolder
Next
End If
End Sub
Function GetFolder(sFOLDER)
On Error Resume Next
Set GetFolder = FSO.GetFolder(sFolder)
If Err.Number <> 0 Then
WScript.Echo "Error connecting to folder: " & sFolder &_
VBlf & "[" & Err.Number & "] " & Err.Description
Wscript.Quit Err.Number
End If
End FUnction
objTextFile.Close
oShell.Popup "Process Complete", 6, strTitle, vbInformation