- NSIS Discussion
- WinVer in NSIS Unicode 2.42
Archive: WinVer in NSIS Unicode 2.42
xbarns
6th January 2009 20:22 UTC
WinVer in NSIS Unicode 2.42
Hi all,
i use this to check for a Windows 2003 Server in the .oninit Function.
Function CheckIfValidOS
!Include WinVer.nsh
${If} ${IsWin2003}
MessageBox MB_OK YES
${Else}
MessageBox MB_OK NO
${Endif}
FunctionEnd
It works with NSIS Unicode 2.38-1 but not with NSIS Unicode 2.42
It also works with the regular NSIS 2.42 (non Unicode)
Regards
Holger
xbarns
6th January 2009 21:12 UTC
Ok i have looked into it some more, i am building the same script with NSIS 2.42 (Unicode and not)
NSIS 2.42 will recognize XP, Windows 2003 Server and Windows 2008 Server
NSIS 2.42 Unicode will only recognize XP but not 2003 or 2008
Funny enough the WinVer of the 2.42 Unicode Version will recognize a W2K3 Server as Windows XP .....
I have now replaced the 2.42 WinVer with the one from 2.38 and it works for my purposes.
jimpark
6th January 2009 21:14 UTC
Hrm, I'm not sure why you are getting an error. I just did a few sample tests myself and it works fine. There has been quite a bit of changes in how include files are used from 2.38 to 2.42. Could that be the problem? Can you try writing a very simple NSI script that reproduces the problem? And this may be a dumb question but "how about completely uninstalling 2.38?" Are all the files gone? Are you including the right WinVer.nsh and not a copy?
jimpark
6th January 2009 21:16 UTC
That's a bit disconcerting. But if you copy the WinVer.nsh from 2.38 it works?
Anders
6th January 2009 21:23 UTC
It might work, but the current WinVer is pretty new, 2.38 would be the old one where as you said, 2003 = XP and 2008 = Vista SP1
Unless you need to specify GetVersionExW in the unicode version, I could see no problems with the one from 2.42
xbarns
6th January 2009 21:26 UTC
@jimpark
this is the script i use
Name WinVerTest
OutFile WinVerTest.exe
Section Test
#
SectionEnd
Function .onInit
!Include WinVer.nsh
${If} ${IsWin2003}
MessageBox MB_OK "Win2003"
${Else}
MessageBox MB_OK "NotWin2003"
${Endif}
FunctionEnd
WinVer.nsh Version 2.38 IT WORKS
WinVer.nsh Version 2.38 DOES NOT WORK
I have also build on a machine that has never had any NSIS installed on it.
@Anders
At this moment i only need to recognize if the machine ist a 2003 Server and that works fine... the 2003 = XP happens with the 2.42 WinVer.nsh
jimpark
6th January 2009 21:33 UTC
Well, I just tested it on Win2003 R2 which requires the test
${If} ${IsWin2003R2}
And it worked. Can you do the following to see what you get for the machines where you say it fails?
${WinVerGetMajor} $1
DetailPrint "Major version = $1"
${WinVerGetMinor} $2
DetailPrint "Minor version = $2"
${WinVerGetBuild} $3
DetailPrint "Build number = $3"
See if that returns meaningful info.
Anders
6th January 2009 21:35 UTC
sorry, I was talking about XP 64 = 2003 (they have the same version number)
edit: ${IsWin2003R2} is special, it does not check the version number at all, you should only use it if you need to detect R2
jimpark
6th January 2009 21:35 UTC
Are you sure your server is not really Windows 2003 R2?
xbarns
6th January 2009 21:38 UTC
OK i get
Major version = 5
Minor version = 1
Build number = 3790
thats on a regular 2003 Server (not R2) i don't have an R2 to test with sadly.
jimpark
6th January 2009 21:40 UTC
Actually, version 5.1 build 3790 is Windows 2003 R2. :)
xbarns
6th January 2009 21:52 UTC
Are you sure? Doesn't it usually display a R2 on the Login Page ?
${IsWin2003R2} does not work there either :(
xbarns
6th January 2009 22:00 UTC
OK found an R2 Server in my VMWare collection
Good News: ${IsWin2003R2} works
Bad News: IT IS Version 5.1 build 3790 (same as my none R2 server)
So you cannot distinguish a R2 from a non R2 using Version and Build number :(
And yes the R2 has "R2" right on the logon screen while the other versions do not.
Anders
6th January 2009 22:41 UTC
thats the point of ${IsWin2003R2}, because the version numbers are the same
Anders
7th January 2009 04:04 UTC
the system plugin in unicode 2.42 is broken
StrCpy $0 "FooBar"
System::Call '*(&t20 "$0")i.r1'
System::Call '*$1(&t4.r2)'
MessageBox mb_ok $2
System::Free $1
should display "FooB" but only displays "Fo" (&w is also broken) so I'm guessing you end up with wrong offsets in the OSVERSIONINFO struct, so it can't check the product type and so Win2003 is converted to XP (XPx64=5.2 workstation)
jimpark
7th January 2009 15:47 UTC
You're right Anders. This is a bug. I've got a fix for it but I won't be releasing another build until I get a few more fixes in. But thanks for finding this!
jimpark
7th January 2009 16:31 UTC
Well, on second thought, the documentation for System does say that the special character '&' should be used to describe BYTES of things. So &tN = N bytes of text. &wN = N bytes of Unicode text. &gN = N bytes of GUID. Should this be changed for the case of &wN and &tN so that it is a count of characters? That's sort of what we assume all the time.
Anders
7th January 2009 18:18 UTC
well, you already have &i for bytes, if there is going to be any hope of using the same system calls for both versions, &t and &w must be sizeof(TCHAR) counts
jimpark
7th January 2009 18:46 UTC
Okay, I will have to change the documentation for the System plugin as well to reflect this change. I think I've got some of the other issues hammered out as well. So expect 2.42.1 soon.
jimpark
8th January 2009 14:27 UTC
Now that 2.42.1 behaves the same as the ANSI version, and this still remains a problem, we need the main NSIS trunk to get this fixed.
kichik
9th January 2009 18:27 UTC
Get what exactly fixed?
jimpark
9th January 2009 18:47 UTC
I may have spoken too soon. I found a bug in xbarns test script that he sent me so it may not be a bug in NSIS at all.
kichik
9th January 2009 19:17 UTC
You can use Source\Tests\WinVer.nsi to test WinVer.
Anders
9th January 2009 19:18 UTC
it seemed to detect 2003 fine in my tests, I just thought you were talking about the ansi docs, the bytes vs chars count bit
jimpark
9th January 2009 19:30 UTC
That's been fixed in 2.42.1. And WinVer.nsi works fine for me as well. So it's really up to xbars to see if it's not a bug in his script.
xbarns
9th January 2009 20:47 UTC
shame on me, as in another post
*imagine sound of forehead hitting tabletop*
You were completely right Jim, almost everything works except finding the difference between 2003 and 2003 R2 i have tested this on a 2003 Standard and a 2003 R2 X64 server these are the only two i have at hand right now.
All else (i tested Vista and XP) works correctly after your correction(s) to my script.
Thanks.