Changement d'adresses ip avec un fichier bat
Résolu/Fermé
tast
-
16 juin 2008 à 22:58
Evalon
Evalon
- Messages postés
- 64
- Date d'inscription
- mercredi 30 septembre 2015
- Statut
- Membre
- Dernière intervention
- 21 juillet 2017
A voir également:
- Script changement adresse ip windows 10
- Changer adresse ip cmd - Meilleures réponses
- Changer adresse ip windows 10 cmd - Meilleures réponses
- Changement d'adresses ip avec un fichier bat ✓ - Forum - Réseau
- Windows - Changer l'adresse IP en ligne de commande avec Netsh - Conseils pratiques - Windows
- Création d'un script ip fixe --> ip auto ✓ - Forum - Réseau
- Changement d'IP automatique ✓ - Forum - Réseau
- Script change ip - Forum - Réseau
1 réponse
le probleme vient du nom de ta connexion reseau local, renomme la en "lan" et ca marche
ex:
@echo off
set carte="LAN"
set adrfixe=192.168.0.14
set masque=255.255.255.0
:question
SET /P lan=Adressage IP 1/DCHP 2/FIXE 3/QUITTER (1/2/3)? :
if %lan%==1 goto IPDHCP
if %lan%==2 goto IPfixe
if %lan%==3 goto Nfin
goto question
:IPfixe
SET /P lan=confirmer l'adressage en IP Fixe 192.168.0.14 (O/N)? :
if %lan%==o goto OKFixe
if %lan%==O goto OKFixe
if %lan%==n goto Nfin
if %lan%==N goto Nfin
goto IPfixe
:OKFixe
netsh interface ip set address %carte% static %adrfixe% %masque%
goto Ofin
:IPDHCP
SET /P lan=confirmer l'adressage en IP Dynamique (O/N)? :
if %lan%==o goto OKDHCP
if %lan%==O goto OKDHCP
if %lan%==n goto Nfin
if %lan%==N goto Nfin
goto IPDHCP
:OKDHCP
netsh interface ip set address %carte% dhcp
goto Ofin
:Nfin
@echo Aucune modification n'a ete appliquee
@echo -
SET /P lan=appuyez sur [ENTREE] pour quitter
goto fin
:Ofin
@echo La nouvelle configuration vient d'etre appliquee
@echo -
SET /P lan=appuyer sur [ENTREE] pour quitter
goto fin
:fin
la en plus tu peux choisir fixe ou dhcp
donc renomme ta connexion en "lan" dans tes connexions reseau et dans ton bat
ex:
@echo off
set carte="LAN"
set adrfixe=192.168.0.14
set masque=255.255.255.0
:question
SET /P lan=Adressage IP 1/DCHP 2/FIXE 3/QUITTER (1/2/3)? :
if %lan%==1 goto IPDHCP
if %lan%==2 goto IPfixe
if %lan%==3 goto Nfin
goto question
:IPfixe
SET /P lan=confirmer l'adressage en IP Fixe 192.168.0.14 (O/N)? :
if %lan%==o goto OKFixe
if %lan%==O goto OKFixe
if %lan%==n goto Nfin
if %lan%==N goto Nfin
goto IPfixe
:OKFixe
netsh interface ip set address %carte% static %adrfixe% %masque%
goto Ofin
:IPDHCP
SET /P lan=confirmer l'adressage en IP Dynamique (O/N)? :
if %lan%==o goto OKDHCP
if %lan%==O goto OKDHCP
if %lan%==n goto Nfin
if %lan%==N goto Nfin
goto IPDHCP
:OKDHCP
netsh interface ip set address %carte% dhcp
goto Ofin
:Nfin
@echo Aucune modification n'a ete appliquee
@echo -
SET /P lan=appuyez sur [ENTREE] pour quitter
goto fin
:Ofin
@echo La nouvelle configuration vient d'etre appliquee
@echo -
SET /P lan=appuyer sur [ENTREE] pour quitter
goto fin
:fin
la en plus tu peux choisir fixe ou dhcp
donc renomme ta connexion en "lan" dans tes connexions reseau et dans ton bat
28 oct. 2015 à 17:51
Je sais que ce sujet date mais j'ai trouvé ce petit script super sympa.
Mais comment faire pour y rajouter la passerelle par défaut et les dns.
Merci d'avance.
Modifié par kaumune le 28/10/2015 à 18:19
Pour une ip de 192.168.0.1 et une passerelle de 192.168.0.2 ça donne
netsh inter ipv4 set address LAN static 192.168.0.1 255.255.255.0 192.168.0.2
pour les dns en exemple 192.168.0.1 en primaire
netsh inter ipv4 delete dns LAN all
netsh inter ipv4 set dns LAN static 192.168.0.1 primary
éventuellement une dns secondaire 192.168.0.3
netsh inter ipv4 add dns LAN 192.168.0.3 index=2
29 oct. 2015 à 00:18
J'avais bricolé une commande comme ça
Mais pourrais-tu si cela ne te dérange pas reprendre la formule ci-dessus et insérer tout ça a l'intérieur car cela j'en suis incapable
Merci d'avance
29 oct. 2015 à 17:21
Merci d'avance
Modifié par kaumune le 30/10/2015 à 07:57