November 5th, 2007, 06:56 AM
Change IP address using vbscript
Apologies if this post is in the wrong area. I'm very new to VB scripting so looking for any help whatsoever.
My aim is to write a HTA to change the local IP address/subnet mask/default gateway from one of 3 presets. Ultimately, the presets will need to be variable so the user can modify them in the future.
I have a working script to change the IP details as follows:
Obviously I can copy the script three times with different IP addresses, but I need to make the settings variable using an input box and store these details for future use. Some form of config file is my first thought, but I wouldn't know how to go about getting the script reading/writing from/to the file.
strComputer = "."
arrIPAddress = Array("10.240.2.40")
arrSubnetMask = Array("255.255.255.0")
arrGateway = Array("10.240.2.200")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
errEnableStatic = objNetAdapter.EnableStatic(arrIPAddress, arrSubnetMask)
errGateways = objNetAdapter.SetGateways(arrGateway)
Any help or pointers towards existing scripts I can modify is very much appreciated.
November 7th, 2007, 10:30 AM
December 17th, 2011, 08:27 AM
where do you put code keep on getting a error
December 19th, 2011, 12:32 PM
This thread is four years old Solaris, I doubt you'll get a reply from the original correspondent.
VBScript of course goes in a plain text file, you name it .vbs and execute that.
“Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
November 28th, 2012, 06:14 PM
how do you change a web ip adress ?
yo i was wondering if uh could change a web ip adress ?