- NSIS Discussion
- GetWindowsVersion does not detect win2k!!
Archive: GetWindowsVersion does not detect win2k!!
caykahve2003
6th October 2004 13:46 UTC
GetWindowsVersion does not detect win2k!!
Hello,
I use GetWindowsVersion function (found in NSIS User Manual) to detect the OS.
What I want to do is to detect the OS and continue according to that. The setup detects win NT 4, and Win XP, but it does not detect win 2000. I tested on two different machines with win 2000. In the function, it goes to the lbl_error label. R1 and R0 are empty only with win 2000.
I attached necessary parts of the code to this message and added ';*****' to the end of the lines I would like to draw your attention. I also put the messages that pop up in comments.
As Win xp and win 2000 go to the same label in the just after the function call, and XP works, I do not think that there is a problem with the rest of the code that I wrote.
Thank you.
Regards,
caykahve
RobGrant
6th October 2004 16:30 UTC
First thing to say I think is that posting threads with titles accusing the developers of not making a good enough method is not a 100% foolproof way of getting the best response from said developers.
Having said that I'm sure they'll be nice.
caykahve2003
6th October 2004 17:10 UTC
Posting a message here does not mean that you are accusing people. You ask for help in the forums because you are doing something wrong but you cannot realize where the error is.
I thought that I had done everything right, but I have seen that it is not so. I cannot understand why it has happened. That is the reason I am writing here. Saying something doesn't work is not accusing people. There are a million reasons why something doesn't work. I have to express the situation as clear as possible.
scully13
6th October 2004 20:28 UTC
I tried it on a Windows 2000 server and it seemed fine. It popped both of the messages that you had marked in the script as not popping. It popped the winnt message and then the 2000 message. The value of $R1 was also 5.0. Is your test machine running Windows 2000 server? I don't think I have any non server 2000 machines here to try it on here.
caykahve2003
7th October 2004 10:00 UTC
Thank you for trying. my machine is Windows 2000, not server. $R1 is '' with mine.
caykahve2003
7th October 2004 11:53 UTC
I put more messages inside the GetWindowsVersion function, and saw that on win2000, it reads the "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" key's CurrentVersion value perfectly as '5.0' but, afterwards does not jump to lbl_winnt from the line
"IfErrors 0 lbl_winnt"
and continues by trying to read the "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" key's VersionNumber value. Afterwards what it reads is null. Therefore, the rest of the code fails.
In the user's manual it says for ReadRegStr: "If the value is present, but is of type REG_DWORD, it will be read and converted to a string and the error flag will be set.
" The value is of type REG_SZ. I could not understand why the error flag is still set.
BTW, I made a trial again on XP: it works correctly and jumps after reading the registry value on "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" .
I will be happy if someone can help me...
kolos
7th October 2004 12:42 UTC
Hi,
Try to use
strcmp $R0 "" 0 lbl_winnt
instead of
IfErrors 0 lbl_winnt
caykahve2003
7th October 2004 13:47 UTC
that works! :)
thank you kolos!
Joost Verburg
7th October 2004 15:14 UTC
The error flag has probably been set somewhere else, I think there should a ClearErrors call before reading the key.
caykahve2003
8th October 2004 07:38 UTC
ClearErrors before ReadRegStr also solved the problem. Tested on 2000, XP, and NT 4.
Thank you Joost Verburg.