
September 7th, 2004, 07:51 AM
|
|
Contributing User
|
|
Join Date: May 2004
Posts: 254
Time spent in forums: 7 h 29 m 48 sec
Reputation Power: 5
|
|
|
WSH: Class SWebmLocator not defiined
Hello, great ones:
I have found the below code on the web for changing an IP address via a vbs script.
However, when I run it I get an error: "Class not found SWbemLocator."
The code is below, and I know that the solution is likely not to difficult. Would someone please point out to me the error of my code?
Code:
Set oLocator = New SWbemLocator
Set oServices = oLocator.ConnectServer(, "root\cimv2")
Set oObject = oServices.Get("Win32_NetworkAdapterConfiguration.Index=0")
Dim asIPAddress
Dim asSubnetMask
asIPAddress = Array("159.105.138.47")
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
-Mike P
|