Jump to content
Sign in to follow this  
nicob2k

Checking Windows Version is greater that WINXP2

Recommended Posts

nicob2k

Hello,

This is my First topic :-) so I'd like to thanks you in advance for all the support you can give me.

I've develop an Installer that automatically install MS SQL SERVER 2005 Express, but some of my clients are running Windows version that is not compatible. In this case, I need to install MSDE.

NB : MS SQL SERVER 2005 Express need at least WIN XP SP2

I'm having trouble finding the OS build number for all Windows product!

Using the @OSBuild function I know that win XP have the @OSBuild = 2600

I don't want to install all version of windows to found this number....

Does anyone have a list?

Thanks a lot

Nicolas

Share this post


Link to post
Share on other sites
weaponx

See how this works.

MsgBox(0,"","Service Pack: " & ServicePackLevel())

Func ServicePackLevel()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"

    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
       For $objItem In $colItems
          Return $objItem.ServicePackMajorVersion
       Next
    Else
       Return 0
    Endif
    
    Return 0
EndFunc

Share this post


Link to post
Share on other sites
nicob2k

After a look on the internet, I found that build number is gradually higher since Windows 98 (probably before, but I don't really mater for my script). So I only do :

CODE
If @OSBuild = 2600 AND @OSServicePack = "Service Pack 2" or @OSBuild > 2600 then

;Install SQL 2005 Express

Else

;Install MSDE

EndIf

PS/ Thanks weaponx for your help, but I think that the @OSServicePack is simpler to use ...

Share this post


Link to post
Share on other sites
weaponx

You should take out the first condition, i'm pretty sure SP2 build number is 2900

Share this post


Link to post
Share on other sites
SmOke_N

See how this works.

MsgBox(0,"","Service Pack: " & ServicePackLevel())

Func ServicePackLevel()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"

    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
       For $objItem In $colItems
          Return $objItem.ServicePackMajorVersion
       Next
    Else
       Return 0
    Endif
    
    Return 0
EndFunc
There is an @OSServicePack.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
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
Sign in to follow this  

×