Archive: Unable to read windows version for vista


Unable to read windows version for vista
Hi All,

I am reading the following registry entry

"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion

using the following command in Vista OS to chekc whether its Vista or not.

ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion

but $R0 always return 5.1, which means XP

I checked currentVersion in the registry its 6.0 only not 5.1

I have test this in Vista Ultimate as wwell as Vista Home
I am using NSIS 2.39


One more problem which i faced in Vista is even if i set SetShellVarContext current, the createshortcut are creating shortcuts for all user instead of current user.


use RequestExectionLevel in your installer


I used "RequestExecutionLevel admin" but still i am getting the version as 5.1

I agree that now i am not facing the second problem that is createshortcut


Just to add that i also used
Winver.nsh
${if} ${IsWinXp}
${if} ${IsWinVista}

it returns true for Xp in Vista OS


I tried using register.dll also , still it did not works

I tried to read
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "ProductName"

but instead of returing windows vista (TM) Home Basics
it returns Microsoft Windows XP


check the properties of your .exe and make sure its not set to compatibility mode


Not sure if this will help or not.


nsExec::ExecToStack '"$SYSDIR\cmd.exe" /c systeminfo |find "OS Name:"'
Pop $0
Pop $1
MessageBox MB_OK "$1"


I don't have Vista so wasn't able to test it, but it works on XP. I used systeminfo to recover similar info with help from LoRd_MuldeR for the syntax. You will probally want to use StrCpy to truncate the string also note there is a carriage return on the end of the string.

Edit: If you want the OS version subsitute "OS Version:" in place of "OS Name:"