Skip to content

Instantly share code, notes, and snippets.

@bahamut45
Last active August 29, 2015 14:07
Show Gist options
  • Save bahamut45/912d5daec943986d6081 to your computer and use it in GitHub Desktop.
Save bahamut45/912d5daec943986d6081 to your computer and use it in GitHub Desktop.
Configure Kvm
@ECHO OFF
SETLOCAL EnableDelayedExpansion
TITLE CONFIGURE KVM GIPRECIA
:rne
echo.
echo.
echo. Entrer le rne de l'etablissement :
echo.
echo.
set /p rne=[]
cls
:menu
echo.
echo.
echo. Merci de choisir une option :
echo. 1 - Renommage de la kvm
echo. 2 - Adressage ip de la kvm
echo. 3 - Configuration des utilisateurs
echo. 4 - Configuration de windows update
echo. et desactivation configuration renforc‚e d'IE
echo. 5 - Redemarrer
echo. 6 - Quitter
set /p option_menu=[1,2,3,4,5,6]
cls
if %option_menu% == 1 (
goto name
)
if %option_menu% == 2 (
goto ip
)
if %option_menu% == 3 (
goto users
)
if %option_menu% == 4 (
goto win_update
)
if %option_menu% == 5 (
goto reboot
)
if %option_menu% == 6 (
goto quit
)
:name
echo.
echo.
echo. Choisir le nom de la kvm:
echo. 1 - cher
echo. 2 - loiret
echo. 3 - indre
echo. 4 - menetou
echo. 5 - cosson
echo.
set /p option_name=[1,2,3,4,5]
cls
if %option_name% == 1 (
set name=cher
set description="Serveur pronote"
)
if %option_name% == 2 (
set name=loiret
set description="Serveur pronote.net et relais"
)
if %option_name% == 3 (
set name=indre
set description="Serveur EDT"
)
if %option_name% == 4 (
set name=menetou
set description="Portail ypareo"
)
if %option_name% == 5 (
set name=cosson
set description="Serveur Ebp Windows"
)
echo.
echo.
echo. Le nom de la kvm sera %name%%rne%
echo. La description de la kvm sera %description%
echo. Etes vous sur de renommer %COMPUTERNAME% en %name%%rne% ?
echo. 1 - Oui
echo. 2 - Retour au menu
set /p option_rename=[1,2]
if %option_rename% == 1 goto rename
if %option_rename% == 2 goto menu
:rename
set newname=%name%%rne%
wmic path win32_computersystem where "Name='%computername%'" CALL rename name='%newname%'
net config server /srvcomment:%description%
cls
goto menu
:ip
echo.
echo.
echo. Adressage ip de %rne% : ?
echo.
echo.
set /p adressage=[x.y.z]
echo %computername% | findstr /i "cher" > nul && set /a lastoctet=170
echo %computername% | findstr /i "loiret" > nul && set /a lastoctet=163
echo %computername% | findstr /i "indre" > nul && set /a lastoctet=167
echo %computername% | findstr /i "menetou" > nul && set /a lastoctet=100
echo %computername% | findstr /i "cosson" > nul && set /a lastoctet=148
echo.
echo.
echo. Adressage de %computername% : %adressage%.%lastoctet%
echo. Validez vous cette adresse ?
echo. 1 - Oui
echo. 2 - Non
set /p option_lastoctet=[1,2]
if %option_lastoctet% == 1 (
set ip_adress=%adressage%.%lastoctet%
)
if %option_lastoctet% == 2 (
echo. Dernier octet de l'adresse ip :
set /p four_octet=[xxx]
echo. !four_octet!
set ip_adress=!adressage!.!four_octet!
)
echo. Adresse ip de %computername% : %ip_adress%
echo. Masque reseau de %computername% : 255.255.255.240
echo. Passerelle de %computername% : %adressage%.173
netsh interface ipv4 set address name="Connexion au r'seau local" source=static %ip_adress% 255.255.255.240 %adressage%.173
echo. Verification de la configuration ip
rem Mise en attente le temps d'application de la configuration
ping -n 5 127.0.0.1 > nul
netsh interface ipv4 show config name="Connexion au r'seau local"
rem cls
goto menu
:users
echo.
echo.
echo. Renommage du compte Administrateur en admin_general : OK
wmic useraccount where "Name='Administrateur'" rename admin_general
echo. Suppression de l'expiration de mot de passe pour admin_general : Ok
wmic useraccount WHERE "Name='admin_general'" set PasswordExpires=FALSE
echo. Affectation du mot de passe pour admin_local
net user admin_local lmdp@%rne%
rem Mise en attente pour v'rification
ping -n 5 127.0.0.1 > nul
cls
goto menu
:win_update
echo.
echo.
echo. Modification des parametres de windows update : OK
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v AUOptions /t REG_DWORD /d 3
echo. Desactivation de la configuration renforc‚e IE
REG ADD "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" /v IsInstalled /t REG_DWORD /d 00000000 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" /v IsInstalled /t REG_DWORD /d 00000000 /f
rem Mise en attente pour v'rification
ping -n 5 127.0.0.1 > nul
cls
goto menu
:reboot
echo.
echo.
echo. Voulez vous redemarrer maintenant ?
echo. 1 - Oui
echo. 2 - Non
set /p option_reboot=[1,2]
if %option_reboot% == 1 goto shutdown
if %option_reboot% == 2 goto menu
:shutdown
shutdown -f -r -t 0
:quit
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment