Jump to content

Making a batch file check what os


Recommended Posts


  • 3 years later...

Just wanted to post and say thanks for this tip. I knew that 'ver' displayed that information but didn't know how to parse it.

Here is what I am using to differentiate between XP and Vista.

@echo off

ver | find "Version 5.1"
if errorlevel 1 goto NotXP
echo XP
goto end

:NotXP
ver | find "Version 6.0"
if errorlevel 1 goto end
echo Vista
goto end

:end

Thanks again

Link to comment
Share on other sites

You can use this :

if exist %SystemDrive%\bootmgr start "" setup.exe

For me,I use that code, it's check uac too ...

if exist %SystemDrive%\bootmgr fsutil | find "administrateur"
if exist %SystemDrive%\bootmgr if "%errorlevel%"=="0" echo UAC ON&&pause&&exit else echo UAC OFF&&start "" setup.exe

Edited by Sonic
Link to comment
Share on other sites

Hey guys i found a post for this but it was for WPI but what i need is the code required to only start the progam if the windows version is 5.2

We really need more information than this, because the way I see it is that if you're creating an unattended disk, you should already know what OS you're installing!

ver | find "Version 5.2"
ver | find "Version 5.1"

This will actually only return the version of the Command Interpreter not the Operating System. Although this is likely to be the same, it is not always true.

if exist %SystemDrive%\bootmgr

Unfortunately if the OS is part of a Dual Boot system with Vista and XP for instance, the bootmgr directory may exist in the root of the XP system drive thus giving a false case.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...