batch

Discussion in 'Website Feedback' started by JX1983, May 5, 2011.

  1. JX1983

    JX1983

    Joined:
    May 5, 2011
    Messages:
    1
    Hi everyone,

    I fairly new to batch files,
    this code works for me bat i need it dissected,
    please help?

    @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
     
    JX1983, May 5, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bonk

    Re: Explorer - Better Batch-Renaming

    bonk, Mar 22, 2006, in forum: Windows Vista Games
    Replies:
    1
    Views:
    994
    Adahn
    May 12, 2006
  2. Woody45

    Fast User Switching via Command Line or Batch File?

    Woody45, Feb 27, 2007, in forum: Windows Vista Administration
    Replies:
    0
    Views:
    333
    Woody45
    Feb 27, 2007
  3. Francois PIETTE

    Vista block batch files from being unzipped

    Francois PIETTE, Jun 23, 2007, in forum: Windows Vista Administration
    Replies:
    12
    Views:
    541
    Francois PIETTE
    Jun 26, 2007
  4. bonk

    Re: Explorer - Better Batch-Renaming

    bonk, Mar 22, 2006, in forum: Windows Vista File Management
    Replies:
    1
    Views:
    382
    Adahn
    May 12, 2006
  5. AdminKen
    Replies:
    4
    Views:
    261
    AdminKen
    Sep 29, 2004
Loading...

Share This Page