Effectivement le batch ne fonctionne que sur un Windows XP en français (les test effectués sous Vista montre que cela fonctionne ; et oui en français aussi
). Désolé, je ne suis pas dans une multi nationale qui utilise des versions anglaises, chinoise, russe... et en anglais cela devrait être
Physical address
Oui cela echoue si on rajoute une carte réseau, notamment si des logiciels de machines virtuelles sont présentes sur la machine, mais dans la plupart des cas de déploiement de masse, une seule carte réseau est présente sur la machine.
Si plusieurs cartes réseau sont présentes, avec la commande ipconfig /all | find "Adresse physique" > mac.txt toutes les adresses mac sont présentes dans le fichier texte (il faut tester de temps en temps).
Pour la modification des 3 informations dans la base de registre c'est une méthode, il existe des logiciels permettant d'effectuer cette tâches mais non automatique. Pour reprendre la citation oui le controlset001 est la bonne clé de registre, les autres controlset permettent de sauvegarder pour permettre d'effectuer la dernière bonne configuration connue (je ne décrit pas la procédure trop long).
et Microsoft modifie bien la base de registre lors du renommage de la machine.
Voici comme promis le code, celui ci fonctionne pour 15 machines.
Lire jusqu'au bout une recette est présente
t1cable:
ce code reste à modifier selon les besoins
[cpp]@echo off
cls
echo Param‚trage du nom de la machine et de l'adresse IP
ipconfig /all | find "Adresse physique" > c:\salle31.txt
fc c:\salle31.txt c:\applications\macadd\ST3115.txt > nul
if %errorlevel% == 1 goto poste14
if %errorlevel% == 0 goto ST3115
:ST3115
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3115 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3115 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3115 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.115 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste14
fc c:\salle31.txt c:\applications\macadd\ST3114.txt > nul
if %errorlevel% == 1 goto poste13
if %errorlevel% == 0 goto ST3114
:ST3114
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3114 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3114 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3114 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.114 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste13
fc c:\salle31.txt c:\applications\macadd\ST3113.txt > nul
if %errorlevel% == 1 goto poste12
if %errorlevel% == 0 goto ST3113
:ST3113
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3113 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3113 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3113 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.113 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste12
fc c:\salle31.txt c:\applications\macadd\ST3112.txt > nul
if %errorlevel% == 1 goto poste11
if %errorlevel% == 0 goto ST3112
:ST3112
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3112 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3112 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3112 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.112 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste11
fc c:\salle31.txt c:\applications\macadd\ST3111.txt > nul
if %errorlevel% == 1 goto poste10
if %errorlevel% == 0 goto ST3111
:ST3111
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3111 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3111 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3111 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.111 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste10
fc c:\salle31.txt c:\applications\macadd\ST3110.txt > nul
if %errorlevel% == 1 goto poste9
if %errorlevel% == 0 goto ST3110
:ST3110
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3110 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3110 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3110 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.110 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste9
fc c:\salle31.txt c:\applications\macadd\ST3109.txt > nul
if %errorlevel% == 1 goto poste8
if %errorlevel% == 0 goto ST3109
:ST3109
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3109 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3109 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3109 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.109 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste8
fc c:\salle31.txt c:\applications\macadd\ST3108.txt > nul
if %errorlevel% == 1 goto poste7
if %errorlevel% == 0 goto ST3108
:OK
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3108 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3108 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3108 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.108 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste7
fc c:\salle31.txt c:\applications\macadd\ST3107.txt > nul
if %errorlevel% == 1 goto poste6
if %errorlevel% == 0 goto ST3107
:ST3107
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3107 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3107 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3107 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.107 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste6
fc c:\salle31.txt c:\applications\macadd\ST3106.txt > nul
if %errorlevel% == 1 goto poste5
if %errorlevel% == 0 goto ST3106
:ST3106
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3106 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3106 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3106 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.106 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste5
fc c:\salle31.txt c:\applications\macadd\ST3105.txt > nul
if %errorlevel% == 1 goto poste4
if %errorlevel% == 0 goto ST3105
:ST3105
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3105 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3105 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3105 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.105 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste4
fc c:\salle31.txt c:\applications\macadd\ST3104.txt > nul
if %errorlevel% == 1 goto poste3
if %errorlevel% == 0 goto ST3104
:ST3104
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3104 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3104 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3104 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.104 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste3
fc c:\salle31.txt c:\applications\macadd\ST3103.txt > nul
if %errorlevel% == 1 goto poste2
if %errorlevel% == 0 goto ST3103
:ST3103
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3103 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3103 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3103 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.103 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste2
fc c:\salle31.txt c:\applications\macadd\ST3102.txt > nul
if %errorlevel% == 1 goto poste1
if %errorlevel% == 0 goto ST3102
:ST3102
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3102 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3102 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3102 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.102 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
goto FIN
oste1
fc c:\salle31.txt c:\applications\macadd\ST3101.txt > nul
if %errorlevel% == 1 goto fin
if %errorlevel% == 0 goto ST3101
:ST3101
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v Hostname /t REG_SZ /d ST3101 /f
reg add "HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters" /v "NV Hostname" /t REG_SZ /d ST3101 /f
reg add "HKLM\SYSTEM\ControlSet001\Control\ComputerName\ComputerName" /v ComputerName /t REG_SZ /d ST3101 /f
netsh interface ip set address "Connexion au r‚seau local" static 10.10.11.101 255.255.255.0 10.10.11.100 gwmetric=1
netsh interface ip set dns "Connexion au r‚seau local" static 10.10.11.100
GOTO FIN
:FIN
[/cpp]
La recette : vive le DOS !!!