Archive: Help: Try this code, please


Help: Try this code, please
Hi please try this code in your PC, it's suppose to read
the version of your windows installed


Function "GetWIN"
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" ProductName
StrCmp $R0 " " +1 +2
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" ProductName
MessageBox MB_OK $R0
FunctionEnd


thanks :D

Are you sure the third line should contain a space between the quotes? As it seems now it will only get the NT name if the non NT name is a space which is not the case on my NT.


So you recommend like this:


StrCmp $R0 "" +1 +2

Why not use the GetWindowsVersion function? I'm sure the results will be more reliable.


mmm, yeah ... but to many line code... it's not that I'm lazzy :)
but if I can get two or three line code the same result, why not?
After all, the Windows version "x.x.x.x" is in the same folder in
the registry.


By the time you figure it out you could have typed the entire code to the GetWindowsVersion function :)


Now works fine :) to me


ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" ProductName
StrCmp $R0 "" +1 +2
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" ProductName
MessageBox MB_OK|MB_ICONSTOP $R0

But is the output the same for every Windows version, or different for Server/Workstation etc.?

And what are the outputs for all versions?

Without this info, you cannot detect the version.


Well...I din't try with those versions of Windows. :(
But in Win95/98/Me/2000/XP, my target OS's, works fine.
I'm write this code for my custom Page with info, of the user-machine.
If any Nsis users have Windows Server, or another Windows version, please
try this code...


i tried it with win server 2003 enterprise edition and $R0 is Microsoft Windows Server 2003


Thanks DOCa Cola, seems to be working :up:


np :)


Info
I don't remember who I stole this from but it is virtually identical and has been in operation in the field for almost 6 months now. It's worked on every Windows platform it's been tried on. I thought it was in the official examples but I couldn't find it when I went back to look for it.


FUNCTION GETWINDOWSVERSION
PUSH $0
PUSH $9
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCmp $0 "" 0 label2000
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber
StrCpy $9 $0 1
StrCmp $9 '4' 0 LABELEND
Goto Label95
Label95:
call FUNCTION95
quit
LABELEND:
MESSAGEBOX MB_OK "This installation can not continue. Please contact BLAH......."
call .onuserabort
quit
label2000:
call FUNCTION2000
quit
FunctionEnd


And secondly,
I tried your code on a Windows 2000 Advanced Data Server and it worked perfectly. (If I wasn't sure my code would work perfectly, I would first check the registry to see if the key queried does indeed contain the data for which I'm seeking.)


Jacob Metro:
If you think that I stole code, dude your wrong :).
I been here at least 3 months and I've never seen that code.
Well, at least didn't dig in the search :rolleyes:
I dive in the registry to see if is it possible to grab the
"string of the Windows name".
I'm only use it has part of my IO final Page. So I use this threat
to kindly ask the nsis users to try the code to see if it work.
If this code, have been writting before, I'd like to be informed by
the creators of Nsis so I retract the *authoring* of the code.
:)


I prefer the Dark Boy code. Is much simpler and give the right result (Microsoft Windows 98). And this code that you posted Jacob Metro, require other functions.


Sorry
Dark Boy,
I was not saying the you stole any code. I was saying that I stole the bulk of the above code from some source.

deguix,
I guess I didn't read the thread as thoroughly as I should have because I thought we were just distinguishing between a Windows NT/XP/2000 operating system and a Windows 95/98/ME one. The previous process will distinguish between the two types based on the location of registry data in each key. (I.E. in Windows 98 a \Windows NT\ key will not exist, and vise-a-versa.)

Sincerely,
Jacob Metro


No problem dude, :D
though welcome to the discussion :p