Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

changing a computer's IP Address


2 replies to this topic

halciber

halciber
  • Full Members
  • 25 posts

Posted 28 November 2007 - 20:06

Hi Everyone,

Is it possible to change the IP Address through the Install? For example, if the target's computer IP Address is 192.168.1.2 and it should be 192.168.1.3, can I do this through the install script?

Thanks,
Mike Goldweber

halciber

halciber
  • Full Members
  • 25 posts

Posted 28 November 2007 - 20:38

I couldn't find anything in DevStudio to change the IP Address; however I did find a command line alternative to this. I used the following:

netsh interface ip set address name="Local Area Network" static 192.168.1.2 255.255.255.0 192.168.1.1 1

where,
192.168.1.2 = new IP address
255.255.255.0 = Subnet mask
192.168.1.1 = default gateway
1 = metric number

Mike

MrSmersh

MrSmersh
  • Full Members
  • 48 posts

Posted 29 November 2007 - 13:07

You could try to execute the following windows scripting host code from IS or to "import" it to script.
If you need help with that just say...

CODE

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.1.2")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.1")
strGatewayMetric = Array(1)

For Each objNetAdapter in colNetAdapters
   errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
   errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
   
//    arrDNSServers = Array("xxx.xxx.xxx.xx")
//    objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)  
   
   If errEnable = 0 Then
       WScript.Echo "The IP address has been changed."
   Else
       WScript.Echo "The IP address could not be changed."
   End If
Next