Modifier adresse ip

bigboss200000 Messages postés 10 Date d'inscription jeudi 30 septembre 2004 Statut Membre Dernière intervention 21 juin 2005 - 20 juin 2005 à 10:31
bigboss200000 Messages postés 10 Date d'inscription jeudi 30 septembre 2004 Statut Membre Dernière intervention 21 juin 2005 - 20 juin 2005 à 15:31
bonjour.
je souhaite modifier l'adresse ip d'un pc soit par wmi soit par une commande systeme
dans un script vbs
voici la
commande systeme:

Set objShell = CreateObject("WScript.Shell")
strCommand = "cmd /c netsh interface ip set ""LAN"" static 10.1.8.245 255.0.0.0 10.1.20.254 2"
Set objExecObject = objShell.Exec(strCommand)

ou
la commande
wmi

strComputer = "."
arrIPAddresses = Array("192.168.0.12")
arrSubnetMasks = Array("255.255.255.0")
intReboot = 0
strIPAddresses = Join(arrIPAddresses, ",")
strSubnetMasks = Join(arrSubnetMasks, ",")

aucune des deux methodes fonctionnent.avez vous un script???
question hors sujet:savez vous comment on fait pour connaitre le nom de l'interface d'une carte reseau!!!
merci beaucoup!!

1 réponse

bigboss200000 Messages postés 10 Date d'inscription jeudi 30 septembre 2004 Statut Membre Dernière intervention 21 juin 2005
20 juin 2005 à 15:31
VOICI LE SCRIPT

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


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

num = InputBox _
("Veuillez spécifié le numero X de fin de l'adresse ip : 10.1.1.X")
If num = "" Then
Wscript.Quit
End If


strIPAddress = Array("10.1.8." & num)
strSubnetMask = Array("255.0.0.0")
strPasserelle = Array("10.1.20.254")
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
0
Rejoignez-nous