-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeip.vbs
More file actions
27 lines (19 loc) · 829 Bytes
/
changeip.vbs
File metadata and controls
27 lines (19 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'
' change ip address
'
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.5.8")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.5.1")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
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