Is there any way using vbscript/WSH to access and modify Windows 2K/XP
TCP/IP Properties?

I need to make a little program that, when the user runs the program and
selects one of two options (radio button:?), they set the TCP/IP properties
to either "Obtain IP address automatically via DHCP" or set a specific
IP/Gateway/DNS/WINS, ect.

I'm still reading all the beginner parts of the win2K scripting guide so
still a hardcore newbie.

I'm hoping someone can point me in the right direction.

Thanks.
Jim

Re: Changing TCP/IP Settings by Torgeir

Torgeir
Tue Jan 25 13:07:22 CST 2005

Jim in Arizona wrote:

> Is there any way using vbscript/WSH to access and modify Windows 2K/XP
> TCP/IP Properties?
>
> I need to make a little program that, when the user runs the program and
> selects one of two options (radio button:?), they set the TCP/IP properties
> to either "Obtain IP address automatically via DHCP" or set a specific
> IP/Gateway/DNS/WINS, ect.
>
> I'm still reading all the beginner parts of the win2K scripting guide so
> still a hardcore newbie.
>
> I'm hoping someone can point me in the right direction.
Hi

You should be able to find what you need here:

Configuring Network Settings
http://www.microsoft.com/technet/scriptcenter/scripts/network/client/modify/default.mspx


For the front end part:

A)
You could consider using HTA (HTML Application) *.HTA files
are in a way HTML files hosted by mshta.exe instead of iexplore.exe:

HTML Applications (HTAs)
http://msdn.microsoft.com/workshop/author/hta/hta_node_entry.asp

A couple of HTA examples here:

http://groups.google.co.uk/groups?selm=%23QAI7UtkAHA.1968%40tkmsftngp04
When running the example in the link above, fill in e.g.
Win32_OperatingSystem in the Enumerate field

http://groups.google.co.uk/groups?selm=%23wIsRfZoCHA.2280%40TK2MSFTNGP12


B)
You could "drive" the InternetExplorer.Application object from your
VBScript.

See e.g. "Editable MsgBox 2" and "Password Dialog" example here:

T Lavedas' WSH Scripts
http://www.pressroom.com/~tglbatch/wshindex.html


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Changing TCP/IP Settings by Jim

Jim
Tue Jan 25 15:18:57 CST 2005

> Hi
>
> You should be able to find what you need here:
>
> Configuring Network Settings
> http://www.microsoft.com/technet/scriptcenter/scripts/network/client/modify/default.mspx
>
>
> For the front end part:
>
> A)
> You could consider using HTA (HTML Application) *.HTA files
> are in a way HTML files hosted by mshta.exe instead of iexplore.exe:
>
> HTML Applications (HTAs)
> http://msdn.microsoft.com/workshop/author/hta/hta_node_entry.asp
>
> A couple of HTA examples here:
>
> http://groups.google.co.uk/groups?selm=%23QAI7UtkAHA.1968%40tkmsftngp04
> When running the example in the link above, fill in e.g.
> Win32_OperatingSystem in the Enumerate field
>
> http://groups.google.co.uk/groups?selm=%23wIsRfZoCHA.2280%40TK2MSFTNGP12
>
>
> B)
> You could "drive" the InternetExplorer.Application object from your
> VBScript.
>
> See e.g. "Editable MsgBox 2" and "Password Dialog" example here:
>
> T Lavedas' WSH Scripts
> http://www.pressroom.com/~tglbatch/wshindex.html
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx

Thanks Torgeir! That led me in the right direction. I was able to
incorporate several of those scripts into one, like so:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

strIPAddress = Array("192.168.6.180")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.6.1")
strGatewayMetric = Array(1)
arrDNSServers = Array("192.168.1.10", "192.168.3.16")

For Each objNetAdapter in colNetAdapters
strPrimaryServer = "192.168.1.15"
strSecondaryServer = "192.168.3.15"
objNetAdapter.SetWINSServer strPrimaryServer, strSecondaryServer

errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNSServers = objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)

If errEnable = 0 Then
WScript.Echo "Sunlife Settings Are In Effect!."
Else
WScript.Echo "There Was An Error. Please Call Jim."
End If
Next

I then used Visual Basic 6 to make a front end that used the VB Script
perfectly, except for the Wscript.Echo object.method, which I worked around.

I've never seen or heard of hta before. I'm definately going to look deeper
into it as it looks like it's something that I could put to good use!

Thanks Again,
Jim