General discussion

Locked

WMI and IP ADDRESS SCRIPT FAILS - help!

By rsp05 ·
I have obtained a VBS/WMI script, included below, which returns the error: "Class Not Defined: SWBemLocator" Code: 800A01FA. Now, I have downloaded and installed the WMI/SDK kit, and I really need a script that sets the IP address. So any help is much appreciated. TIA. Script:
Dim strWBEMClass
Dim SWbemLocator
Set oLocator = New SWbemLocator
Set oServices = oLocator.ConnectServer(, "root\cimv2")
Set oObject = oServices.Get("Win32_NetworkAdapterConfiguration.Index=0")
Dim asIPAddress
Dim asSubnetMask
asIPAddress = Array("168.108.135.65")
asSubnetMask = Array("255.255.255.0")
Set oMethod = oObject.Methods_("EnableStatic")
Set inParam = oMethod.InParameters.SpawnInstance_()
inParam.IPAddress = asIPAddress
inParam.SubnetMask = asSubnetMask
Set outParam = oObject.ExecMethod_("EnableStatic", inParam)
If outParam.returnValue = 0 Then
MsgBox "Method Succeeded."
Else
MsgBox "Method Failed. " & CStr(outParam.returnValue)
End if

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

WMI and IP ADDRESS SCRIPT FAILS - help!

by mark.thomson In reply to WMI and IP ADDRESS SCRIPT ...

You can only do late binding in VBScript so instead of
Set oLocator = New SwBemLocator

you need
Set oLocator = CreateOBject("WbemScripting.SWbemLocator")

instead
(all on one line of course)

HTH

Collapse -

WMI and IP ADDRESS SCRIPT FAILS - help!

by rsp05 In reply to WMI and IP ADDRESS SCRIPT ...

Thanks for your response. However, now I am getting a VBScript pop-up msg: Method Failed.84 Any idea?

Collapse -

WMI and IP ADDRESS SCRIPT FAILS - help!

by Shanghai Sam In reply to WMI and IP ADDRESS SCRIPT ...

According to MSDN when Win32_NetworkAdaptorConfiguration.EnableStatic returns 84 it means "IP not enabled on adaptor"

so try something like enumerating through all available instances of Win32_NetworkConfiguration until you find one with its IPEnabled property = true and then try and set its IP address

Collapse -

WMI and IP ADDRESS SCRIPT FAILS - help!

by rsp05 In reply to WMI and IP ADDRESS SCRIPT ...

Poster rated this answer

Collapse -

WMI and IP ADDRESS SCRIPT FAILS - help!

by rsp05 In reply to WMI and IP ADDRESS SCRIPT ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums