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
| strIP1 = inputbox("Veuillez entre l'adresse IP "& chr(13) & "(Format : "&chr(34)&"192.168.1.141"&chr(34)&")", "IP?")
strmask1 = InputBox ("Veuillez entrer le masque de sous réseau"& chr(13) & "(Format : "&chr(34)&"255.255.255.0"&chr(34)&")", "Mask?")
strIP = Array(strIP1)
strmask = Array(strmask1)
strGateway = Array("")
strGatewayMetric = Array(1)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIP, strmask)
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 |
Partager