InstallShield Tips and Techniques

September 5, 2013

How to determine Windows Server 2012 OS in InstallScript function

Filed under: Reference Materials — shieldmaster @ 10:51 pm

I needed to determine whether I was installing on a Windows Server 2012 – but within the online help for InstallShield 2013, it did not provide the VersionNT/WinBuild/OS Major/OS Minor values that would assist in scripting the function.

I went ahead and created a testbed.MSI that would output the values for each, and then created a sample script to allow you to quickly determine the values.

 

// ************************************************************************************************

//        OS SYSTEM              VersionNT       WindowsBuild          OS Major OS Minor

//        WinServer 2008 R2        601    greater than 7100           6    0

//        Windows 7             601     greater than 7100           6    0

//        Windows 7 SP1        601     greater than 7601        6    0

//        Windows 8             602    greater than 9200        6    0

//        WinServer 2012        602    greater than 9200           6    0

// ************************************************************************************************

 

nzSize = 256;

MsiGetProperty (ISMSI_HANDLE, "VersionNT", szVersionNT, nzSize);

      MessageBox ( "INFO - VersionNT is: " + szVersionNT, INFORMATION);

 

     

// Check if Operating System is Windows 7 or Win2008 R2

if ( szVersionNT = "601") then 

 

      if (SYSINFO.nOSProductType = VER_NT_WORKSTATION) then

          //; for Windows 7, this is TRUE; for Windows Server 2008, it is FALSE.

        szLogMessage = "ISI-->   INFO - Operating System is Windows 7";

        MessageBox (szLogMessage, INFORMATION);    

      else

        szLogMessage = "ISI-->   INFO - Operating System is Windows Server 2008 R2";

        MessageBox (szLogMessage, INFORMATION);    

      endif;

 

endif;

 

// Check if Operating System is Windows 8 or Win2012

if ( szVersionNT = "602") then 

 

      if (SYSINFO.nOSProductType = VER_NT_WORKSTATION) then

          //; for Windows 8, this is TRUE; for Windows Server 2012, it is FALSE.

        szLogMessage = "ISI-->   INFO - Operating System is Windows 8";

        MessageBox (szLogMessage, INFORMATION);    

      else

        szLogMessage = "ISI-->   INFO - Operating System is Windows Server 2012";

        MessageBox (szLogMessage, INFORMATION);    

      endif;

 

endif;

 

Hope this helps!

ShieldMaster

Advertisements

4 Comments »

  1. Can this logic be extended to determine Windows 8.1 and Windows Server 2012 R2?

    Comment by Clayton Dean — October 22, 2013 @ 2:35 pm

    • This script should work fine in an InstallScript project since it’s using InstallShield scripting. As for Win8.1 – you should get the correct parameters from the InstallShield website.
      ShieldMaster

      Comment by shieldmaster — October 22, 2013 @ 9:29 pm

  2. If so, how would this work in an InstallScript (non-MSI) project?

    Comment by Clayton Dean — October 22, 2013 @ 2:36 pm

  3. This will not work for non-MSI projects.
    For installscript projects, need to use
    SYSINFO.nWinMajor = 6
    SYSINFO.nWinMinor = 2 properties

    if(SYSINFO.nOSProductType != VER_NT_WORKSTATION)then
    if(SYSINFO.nWinMajor == 6 && SYSINFO.nWinMinor>= 2 ) then
    //Your Logic
    endif;
    endif;

    Comment by Vinay — September 15, 2014 @ 4:27 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: