Skip to content
⌘ NSIS Forum Archive

GetVersion:WindowsName

7 posts

JayGunter#

GetVersion:WindowsName

Hi all,

I'm having a little trouble with my script. I am using the GetVersion plug-in from Stu. What I would like to do is detect the OS and have the script preform a specific function for W95, 98 & ME and a different function for WNT, 2K, XP, and Server2K3. Below is what I have been using in my section..but it is not working correctly.

Section "Installer Section"
 GetVersion::WindowsName
  Pop $R0
;Looking for a DOS based OS
 IntCmp $R0 "95"      DOSKERNEL
 IntCmp $R0 "95 OSR2" DOSKERNEL
 IntCmp $R0 "98"      DOSKERNEL
 IntCmp $R0 "98 SE"   DOSKERNEL
 IntCmp $R0 "ME"      DOSKERNEL
;Looking for an NT based OS
 IntCmp $R0 "NT"             NTKERNEL
 IntCmp $R0 "2000"           NTKERNEL
 IntCmp $R0 "XP"             NTKERNEL
 IntCmp $R0 "XP x64"         NTKERNEL
 IntCmp $R0 "Server 2003"    NTKERNEL
 IntCmp $R0 "Server 2003 R2" NTKERNEL
MessageBox MB_OK|MB_ICONSTOP "Your OS is neither a DOS or NT Based system!"
ABORT
DOSKERNEL:
MessageBox MB_OK|MB_ICONSTOP "You have a DOS based OS"
ABORT
NTKERNEL:
MessageBox MB_OK|MB_ICONSTOP "You have a NT based OS."
ABORT
SectionEnd 
JayGunter#
Thanks, that seems to straighten everything out.

One last question, Does anyone know a way to shorten the code to make it any simpler?
Anders#
!include "WinVer.nsh"

${If} ${IsNT}
DetailPrint "Running on NT."
${Else}
DetailPrint "Not running on NT."
${EndIf}
Afrow UK#
Yep for things like this no need for the plug-in. You need to include LogicLib.nsh as well.

Stu