Connecting to WMI through vb.net

ravenfrost

New member
Joined
Aug 20, 2007
Messages
3
Programming Experience
Beginner
Hello,

I cannot get this code to work. I want to connect to wmi as a different user but the code just keeps bombing out. Does anyone know how to connect wmi to a remote machine as a different user? I can get it to work in vbscript but not in vb.net. Thanks.

VB.NET:
Dim SWBemlocator, objWMIService, colItems, objItem
SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
objWMIService = SWBemlocator.ConnectServer(strHost, "root\CIMV2", strUser, strPass)
colItems = objWMIService.ExecQuery("select * from Win32_PingStatus where address = '" & strHost & "'")
For Each objItem In colItems
blah blah...
Next
 
You know, .Net Framework has WMI interactivity also through System.Management namespace, try WMI Code Creator to get code samples.
 
Back
Top