VBScript remote connection and query to Windows 7 machines
I have written a script that connects to a computer remotely by using the SWbemLocator and SWbemServices. Given that I'm querying both Windows XP and Windows 7 machines, I have to set the folder directories to C:\Documents and Settings and C:\Users, respectively. The script runs fine for Windows XP machines, but it returns "Path not found" for Windows 7 machines. I have checked and there is a C:\Users directory in the Win7 machines, so I don't know what wrong.
I'm thinking that the connection establishment for win7 machines is different from winXP, but I haven't found any other options. Here is a snippet of the code that shows how I'm connecting:
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer _
(ComputerName & "domain", "root\cimv2", "admin", "password")
objSWbemServices.Security_.ImpersonationLevel = 3
When I connected to a Win7 machine using the code above to find out what operating system was running on them it worked fine, but when I try to query files and folders, it returns the "Path not found" error. Let me know if you have faced a similar problem, or if you could give me any hints.