Question Locked

VB Script - easy I'm sure

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi guys,

I need to have a script that prompts for an IP address to be entered and this then puts it in the field to change the IP. Currently I have to edit the script manually, save it then run it. The working code so far is:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True")

strIPAddress = Array("192.168.xxx.xxx")
strSubnetMask = Array("255.255.255.0")

For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
Next

I just want to have a user input box which prompts for the IP address and inputs this into the strIPAddress array.

Any clues? Sure its an easy one for a VB expert.

Thanks.

4 replies

by rob miners

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True")

strIPAddress = array(InputBox("Enter IP Address", "IP Address", "192.168.xxx.xxx"))

strSubnetMask = array(InputBox("Enter SubnetMask", "SubnetMask", "255.255.255.0"))

For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
Next

This discussion is closed to new replies.