Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    I'm trying to create a batch file that runs from an autoloaded CD on either XP or Vista. Is there some way to determine which OS is running from within a batch file?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    Try this:

    [codebox]@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

    echo Machine Vista.
    autoload CD in Vista code goes here
    goto exit

    :ver_2003
    echo Windows 2003
    autoloaded CD in 2003 goes here
    goto exit

    :ver_xp
    echo Windows XP
    autoloaded CD in XP goes here
    goto exit

    :ver_2000
    echo Windows 2000
    autoloaded CD in 2000 goes here
    goto exit

    :ver_nt
    echo Windows NT
    autoloaded CD in NT goes here
    goto exit

    :exit[/codebox]
    Jerry

  3. #3
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    Thanks a bunch. I'll give it a shot.

  4. #4
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    After giving the code a second look do I understand that finding Vista = not finding all the other?

  5. #5
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,438
    Thanks
    33
    Thanked 196 Times in 176 Posts
    [quote name='Chuck Tucker' post='791417' date='31-Aug-2009 03:50']After giving the code a second look do I understand that finding Vista = not finding all the other?[/quote]
    A better test is to look for the version number... For example XP is 5.1. The full string is [Version 5.1.2600]

    Your Vista Will Vary...
    BATcher

    "The trouble with quotes on the internet is that you can never know if they are genuine."
    Abraham Lincoln
    

  6. #6
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    Actually, I'm looking for generic versions of XP & Vista as the batch file is used on various machines with unknown version numbers.

  7. #7
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,438
    Thanks
    33
    Thanked 196 Times in 176 Posts
    [quote name='Chuck Tucker' post='791485' date='31-Aug-2009 15:54']Actually, I'm looking for generic versions of XP & Vista as the batch file is used on various machines with unknown version numbers.[/quote]
    Well, if you don't believe me, work your way through this!
    BATcher

    "The trouble with quotes on the internet is that you can never know if they are genuine."
    Abraham Lincoln
    

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •