Creer fichier.bat

McRACHID Messages postés 35 Statut Membre -  
KX Messages postés 19031 Statut Modérateur -
Bonjour,

ecrire un fichier .bat qui detect le type du OS cad xp,vista ou seven

2 réponses

  1. KX Messages postés 19031 Statut Modérateur 3 020
     
    Tu peux utiliser ceci, c'est court et précis :
    VER
    PAUSE

    Si tu veux quelque chose de plus complet (mais plus long) il y a aussi :
    SYSTEMINFO
    PAUSE
    1
  2. Rollyo Messages postés 34 Statut Membre 2
     
    Bonjour, j'ai trouvé un site pour toi

    http://www.malektips.com

    En gros il faut que tu copie/colle le contenu ci-dessous dans le bloc note (Notepad ++ est ton ami :p). Ensuite tu enregistre au format .bat sur ton bureau par exemple et tu l'exécute.

    Voici le contenu :

    @echo off

    ver | find "2003" > nul
    if %ERRORLEVEL% == 0 goto ver_2003

    ver | find "XP" > nul
    if %ERRORLEVEL% == 0 goto ver_xp

    ver | find "2000" > nul
    if %ERRORLEVEL% == 0 goto ver_2000

    ver | find "NT" > nul
    if %ERRORLEVEL% == 0 goto ver_nt

    if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit

    systeminfo | find "OS Name" > %TEMP%\osname.txt
    FOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i

    echo %vers% | find "Windows 7" > nul
    if %ERRORLEVEL% == 0 goto ver_7

    echo %vers% | find "Windows Server 2008" > nul
    if %ERRORLEVEL% == 0 goto ver_2008

    echo %vers% | find "Windows Vista" > nul
    if %ERRORLEVEL% == 0 goto ver_vista

    goto warnthenexit

    :ver_7
    :Run Windows 7 specific commands here.
    echo Windows 7
    goto exit

    :ver_2008
    :Run Windows Server 2008 specific commands here.
    echo Windows Server 2008
    goto exit

    :ver_vista
    :Run Windows Vista specific commands here.
    echo Windows Vista
    goto exit

    :ver_2003
    :Run Windows Server 2003 specific commands here.
    echo Windows Server 2003
    goto exit

    :ver_xp
    :Run Windows XP specific commands here.
    echo Windows XP
    goto exit

    :ver_2000
    :Run Windows 2000 specific commands here.
    echo Windows 2000
    goto exit

    :ver_nt
    :Run Windows NT specific commands here.
    echo Windows NT
    goto exit

    :warnthenexit
    echo Machine undetermined.

    :exit

    Ps : le site est en anglais

    --------------------
    Rollyo
    0