I'm running into an error during WMI processing of the available folders on a drive of our servers to perform an inventory of the paths and the security that is present. We need this info for migration preparations.
Once I run my simple dir-processing code against fro example the c:\windows folder it reports the subfolders exacly as expected.
But once I change my query-parameters to "(drive = "f:" AND path LIKE "\\gebruikers\\groups\\%")" in order to get the folders from drive f: the script runs for a few seconds and then exists with error "The remote procedure call failed". I set the WMI logging to verbose and in the WMI-logging file it shows "Error 800706be occured executing request for select __RELPATH, drive, path, name, filename from Win32_Directory where (drive = "f:" AND path LIKE "\\gebruikers\\groups\\%")"
My current code to list the folders is:
Const forAppending = 8
Dim objFS, objLog, objLocator, objWMIService, colFolders, objFolder, strLine
Set objFS = CreateObject("Scripting.FilesystemObject")
Set objLog = objFS.CreateTextFile(".\foldertree.log",true)
Set objLog = Nothing
strComputer = "."
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer (strComputer, "root/cimv2")
objWMIService.Security_.impersonationlevel = 3
objWMIService.Security_.Privileges.AddAsString "SeSecurityPrivilege", True
objWMIService.Security_.Privileges.AddAsString "SeBackupPrivilege", True
Set colFolders = objWMIService.ExecQuery("Select drive,path,name,filename from Win32_Directory where (drive='f:' and path like '\\gebruikers\\groups\\%')")
'wscript.echo "[" & colFolders.count & "] folders found in groups: now log folders ..."
For Each objFolder in colFolders
strLine = objFolder.drive & objFolder.path & objFolder.filename
Call fWrite2Log(".\foldertree.log", strLine, forAppending)
Set objLog = Nothing
Set objFS = Nothing
Function fWrite2Log(strLogfile, strLogstring, iMode)
Set objTMP = objFS.openTextFile(strLogfile, iMode)
Set objTMP = Nothing
The strange thing (for me) is that the folder where the script fails is never the same, so it seems like some buffer thing or so but I can't get my finger on it.
I hope someone can help me out here. I've read quite a lot on the web already but couldn't find a solution so far.
Best regards and many thanks in advance