I have the following code:
Function ExistShare(strServer, strUser)
Set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objWMILocator.ConnectServer (strServer, "root\cimv2", "NSWIDCFPT03\WMIQuerys", "XXXPASSWORDXXX")
objWMIService.Security_.ImpersonationLevel = 3
'Set colShares = objWMIService.ExecQuery ("Select * from Win32_Share WHERE name = '" & strFolderSharedName_0 & "\" & strUser & "'")
wscript.echo "strDriveMapping2 : " & strDriveMappingPhysicalPath
'set colShares = objWMIService.Get("Win32_Directory.Name = '" & strDriveMappingPhysicalPath & "'")
set colShares = objWMIService.execQuery ("select * from win32_directory where name = '" & strDriveMappingPhysicalPath & "'")
If colShares.Count < 1 Then
ExistShare = False
Else
ExistShare = True
End If
End Function
It has an error on this line (If colShares.Count < 1 Then
) saying
Error: Invalid Query
Source: SWbemObjectSet
Any ideas?