locked
Demande d'aide pour des scripts batch sous Windows 7 RRS feed

  • Question

  • Bonjour à la communauté Technet,

    j'ai besoin de votre expérience et aide pour résoudre un souci :

    Je voulais savoir les codes retours possible pour les commandes IPK et ATO ? (j'ai repéré pour l'instant 0  ;  -1073418203 ). Je voulais savoir si faire

    if %errorlevel% EQU 0 (

    echo tout fonctionne

    )

    if %errorlevel% NEQ 0 (

    echo erreur lors de l'activation de Windows

    )

    suffisait pour crée un log ou l'on sait si oui ou non Windows est activé.

    @echo *********activation windows********* >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    cscript //B "%windir%\system32\slmgr.vbs" /ipk XXXX-XXXX-XXXX-XXXX-XXXX
    @echo IPK traite >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    cscript //B "%windir%\system32\slmgr.vbs" /ato 
    @echo ato traite >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo activation Windows traitee >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"


    Ensuite, j'aimerai savoir (si possible) comment faire pour faire la distinction lors de la suppression de l' Utilisateur dont le nom est Utilisateur:

    Il renvoie:

    0 => Aucune erreur lors de la suppression de l'utilisateur est bonne (ça c'est bon, vu que le code retourné est unique)


    mais là ou y'a un souci, c'est quand il retourne 2 pour trois choses choses:

    la 1ere: quand l'utilisateur n'existe plus

    la 2éme : quand l'utilisateur n'a pas les droits pour supprimé l'utilisateur

    la 3éme: quand il y a vraiment une erreur lors de la suppression de l'utilisateur

    Comment je peux faire la distinction entre la 1ere, 2éme et 3 éme ?

    net user Utilisateur /delete
    @echo gestion utilisateur traitee >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    
    @rmdir C:\Users\Utilisateur /s /q
    dir C:\Users\Utilisateur
    if %errorlevel% EQU 0 (
    echo Erreur: le dossier C:\sources n'a pas ete supprime >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    if %errorlevel% NEQ 0 (
    echo Le dossier sources est bien ete supprime >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"

    Actuellement, j'ai fais ceci pour les étapes ATO et IPK mais je ne sais pas si il couvre l'ensemble des erreurs éventuelles lors de ces étapes. Qui plus est, cela ne dit pas si Windows est ou n'est pas activé. Y'a t'il un moyen de vérifié si Windows est bien activé ? (sans devoir installer quelques choses sur l'ordinateur )

    @echo off
    cls
    
    if not exist D:\log##%computername%\ ( 
    md D:\log##%computername%\
    )
    
    @echo Date de creation: %DATE% > "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo Heure creation:  %time:~0,8% >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    echo Nom utilisateur: %USERNAME% >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    echo Nom ordinateur: %COMPUTERNAME% >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    cls
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    
    
    @echo *********activation windows********* >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    cscript //B "%windir%\system32\slmgr.vbs" /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXX
    if %errorlevel% EQU 0 (
    echo Aucune erreur lors de l'etape IPK >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    if %errorlevel% NEQ 0 (
    echo Erreur lors de l'étape IPK.Windows n'est donc pas active >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    cscript //B "%windir%\system32\slmgr.vbs" /ato 
    
    if %errorlevel% EQU 0 (
    echo Aucune erreur lors de l'etape ATO >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    if %errorlevel% NEQ 0 (
    echo Erreur lors de l'étape ATO.Windows n'est donc pas active >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"

    Merci d'avance

    Louis Peperman




    mardi 21 mai 2013 08:48

Réponses

Toutes les réponses

  • Finalement, je me suis arrangé autrement en utilisant de manière détourné des commandes de base qui si elles échouaient renvoyé un code d'erreur (1 ou 2)

    @echo off
    cls
    
    if not exist D:\log##%computername%\ ( 
    md D:\log##%computername%\
    )
    
    @echo Date de creation: %DATE% > "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo Heure creation:  %time:~0,8% >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    echo Nom utilisateur: %USERNAME% >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    echo Nom ordinateur: %COMPUTERNAME% >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    cls
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    
    
    @echo ----------------------------------------------------------------------- Fichier Log ----------------------------------------------------------------------- >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    
    
    @echo ***************************************** activation windows ***************************************** >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    cscript //B "%windir%\system32\slmgr.vbs" /ipk XXXXX-XXXXXX-XXXXX-XXXXX-XXXXX
    if %errorlevel% EQU 0 (
    @echo Aucune erreur lors de l'etape IPK >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    if %errorlevel% NEQ 0 (
    @echo Erreur lors de l'étape IPK. La cles windows n'est donc pas active >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    cscript //B "%windir%\system32\slmgr.vbs" /ato 
    if %errorlevel% EQU 0 (
    @echo Aucune erreur lors de l'etape ATO >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    if %errorlevel% NEQ 0 (
    @echo Erreur lors de l'étape ATO. La cles windows n'est donc pas active >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    [COLOR="Red"]
    @echo activation Windows traitee >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"[/COLOR]
    
    
    @echo ***************************************** gestion utilisateur ***************************************** >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    net user Administrateur /active:yes
    IF %ERRORLEVEL% EQU 0 (
    CLS
    @echo Le compte Administrateur Local est bien actif >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    IF %ERRORLEVEL% NEQ 0 (
    CLS
    @echo Echec lors de l'activation du compte Administrateur Local >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    )
    
    net user Utilisateur
    if %errorlevel% NEQ 0 (
    @echo l'utilisateur n'existe pas >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    if %errorlevel% EQU 0 (
    net user Utilisateur /delete
    net user Utilisateur
    		if %errorlevel% EQU 0 (
    			@echo Erreur lors de la suppression du compte : Utilisateur >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    			@echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    
    		if %errorlevel% NEQ 0 (
    			@echo Le compte Utilisateur est bien supprime >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    			@echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" ))
    
    dir C:\Users\Utilisateur
    if %errorlevel% NEQ 0 (
    echo Le dossier C:\Users\Utilisateur n'existe pas >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    if %errorlevel% EQU 0 (
    @rmdir C:\Users\Utilisateur /s /q
    dir C:\Users\Utilisateur
    		if %errorlevel% EQU 0 (
    			@echo Erreur: le dossier C:\sources n'a pas ete supprime >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    			@echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    		
    		if %errorlevel% NEQ 0 (
    			@echo Le dossier sources est bien supprime >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    			@echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" ))
    
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    
    @echo ***************************************** gestion de l'autologin ***************************************** >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    
    set autoadminlogon=1
    set defaultdomainname=hjgftc
    set defaultusername=tesvdv
    set defaultpassword=qsddvd
    
    for /f "tokens=3*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon') do (
    if /i "%autoadminlogon%" EQU "%%a" (
    @echo La valeur de la cles de registre AutoAdminLogon est deja de : %%a >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt")
    if /i "%autoadminlogon%" NEQ "%%a" (
    REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d "%autoadminlogon%" /f
    for /f "tokens=3*" %%b in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon') do (
    if /i "%autoadminlogon%" EQU "%%b" (
    @echo La valeur: AutoAdminLogon bien modifiee. La valeur de AutoAdminLogon est de: %%b >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt")
    if /i "%autoadminlogon%" NEQ "%%b" (
    @echo Erreur lors de la modification de la valeur: AutoAdminLogon. La valeur de AutoAdminLogon est: %%b >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" ))
    ))
    
    for /f "tokens=3*" %%c in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName') do (
    if /i "%defaultdomainname%" EQU "%%c" (
    @echo La valeur de la cles de registre DefaultDomainName est deja : %%c >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt")
    if /i "%defaultdomainname%" NEQ "%%c" (
    REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d "%defaultdomainname%" /f
    for /f "tokens=3*" %%d in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName') do (
    if /i "%defaultdomainname%" EQU "%%d" (
    @echo La valeur: DefaultDomainName bien modifiee. La valeur de DefaultDomainName est: %%d >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    if /i "%defaultdomainname%" NEQ "%%d" (
    @echo Erreur lors de la modification de la valeur: DefaultDomainName. La valeur de DefaultDomainName est: %%d >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" ))
    ))
    
    for /f "tokens=3*" %%e in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName') do (
    if /i "%defaultusername%" EQU "%%e" (
    @echo La valeur de la cles de registre DefaultUserName est deja : %%e >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    if /i "%defaultusername%" NEQ "%%e" (
    REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d "%defaultusername%" /f
    for /f "tokens=3*" %%f in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName') do (
    if /i "%defaultusername%" EQU "%%f" (
    @echo La valeur: DefaultUserName bien modifiee. La valeur de DefaultUserName est: %%f >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    if /i "%defaultusername%" NEQ "%%f" (
    @echo Erreur lors de la modification de la valeur: DefaultUserName . La valeur de DefaultUserName est: %%f >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" ))
    ))
    
    for /f "tokens=3*" %%g in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword') do (
    if /i "%defaultpassword%" EQU "%%g" (
    @echo La valeur de la cles de registre DefaultUserName est deja : %%g >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt"
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" )
    if /i "%defaultpassword%" NEQ "%%g" (
    REG add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d "%defaultpassword%" /f
    for /f "tokens=3*" %%h in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword') do (
    if /i "%defaultpassword%" EQU "%%h" (
    @echo La valeur: DefaultPassword bien modifiee. La valeur de DefaultPassword est: %%h >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" ) 
    if /i "%defaultpassword%" NEQ "%%h" (
    @echo Erreur lors de la modification de la valeur: DefaultPassword. La valeur de DefaultPassword est: %%h >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" 
    @echo. >> "D:\log##%computername%\scriptserv_%computername%##%DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4%.txt" ))
    
    exit



    Si vous voyez un moyen d'améliorer le code, je suis toujours à l'écoute de bons conseils :=)

    Je recherche maintenant juste un moyen de faire un log :

    Si Windows activé => echo Windows est bien activé
    Si Windows pas activé => echo Windows connait un problème d'activation

    sachant que le IPK et ATO à beau bien se dérouler, ce n'est pas pour moi un preuve suffisante que Windows est bien activé  [COLOR="Red"](je l'ai mis en rouge dans le code au dessus)[/COLOR]



    mardi 21 mai 2013 14:58
    • Marqué comme réponse Florin Ciuca lundi 27 mai 2013 08:48
    jeudi 23 mai 2013 08:53
  • le souci est que je suis actuellement sur du batch et je ne souhaite pas devoir faire à un autre batch externe.

    Néanmoins, merci de votre aide Dan Bajenaru


    jeudi 23 mai 2013 13:18