SUPINFO International University

SUPINFO Institute of Information Technology
Laboratoire Microsoft




Assigner une adresse IP statique

Accueil > Script > reseau > Assigner une adresse IP statique

Assigner une adresse IP statique

Par Nicolas MILBRAND, LABORATOIRE SUPINFO DES TECHNOLOGIES MICROSOFT
Publiée le 24/03/2005 vers 19h.

Description :
Ce script VBS assigne l'adresse IP 192.168.1.69 avec un masque 255.255.255.0 et une passerelle 192.168.1.100 à un ordinateur.

Script :


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.69")
strSubnetMask = Array("255.255.255.0")
strPasserelle = Array("192.168.1.100")
strGatewayMetric = Array(1)

For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strPasserelle, 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



Proposer un script

Notre avis :

Votre avis :

Réactions :
0

Votants :
5

Visites :
16393

1
2
3
4
5

Script Suivant :

Assigner un suffixe DNS



Retrouvez ci-dessous les autres sections du Laboratoire Microsoft