Question

Locked

VB Script - easy I'm sure

By martin ·
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.

This conversation is currently closed to new comments.

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

All Answers

Collapse -

Try This

by Jacky Howe In reply to VB Script - easy I'm sure

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

Collapse -

Works

by martin In reply to Try This

Cheers Jacky, works a treat.

Collapse -

No Problems

by Jacky Howe In reply to Works

Glad I could help.

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

Related Discussions

Related Forums