此查询在我的本地机器上运行良好:
strComputer = "."
drive = "C:"
path = "\\path\\to\\local\\folder\\"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '"&path&"' and drive='"&drive&"'")
If colFiles.Count < 1 Then
Wscript.Echo "Folder does not exist"
Else
Wscript.Echo "Folder does exist"
End If
但是当我尝试查询映射的网络驱动器时,程序失败并显示“文件夹不存在”。但我确信这是文件的正确路径。
唯一改变的部分是:
drive = "Z:"
path = "\\path\\to\\mapped\\drive\\folder\\"
关于为什么这不起作用的任何线索?