GFORCE100
3rd December 2004 22:15 UTC
OS detection
Hello,
What would be the best way to allow the installer to only start on the following OS's:
Windows 2000
Windows XP
Windows 2003
In other words not Windows Me, 98 or earlier at all.
I was thinking it would run a function from in the initialize section of the script and display an error message should an unsupported OS be detected. Then it would simply terminate the installer process.
Thanks
Jnuw
3rd December 2004 22:45 UTC
I can think of 2 ways. First you could do a simple initialize function as you suggested, like this:
Function .onInit
IfFileExists "$SYSDIR\mmc.exe" 0 WrongOS
goto End
WrongOS:
MessageBox MB_ICONEXCLAMATION "It does not appear that bla bla bla"
Abort
End:
FunctionEnd
Where mmc.exe (Manage Window) is a file that only 2k, xp, and 2003 OSs would have. You could probably find several files to do the job.
The other idea would be to use the ver command. If you type ver in a command prompt you get the windows version. Pipe that into a text file (or ini) and search for the text your after.
I'm new at this, so anyone feel free to correct me if i'm leading GFORCE100 down the wrong path.
zarged
4th December 2004 11:31 UTC
Check the archive for sunjammers windows version function.
GFORCE100
4th December 2004 17:21 UTC
Originally posted by zarged
Check the archive for sunjammers windows version function.
Thank you both for your thoughts.
Please tell me how would I use the value in the $R0 variable. I have looked through the manual and cannot find any conditional operands such as IF or SWITCH/SELECT CASE.
The way I see it it would be something like:
If $R0 == "95" or "98" or "Me" Then
Msgbox ........
Terminate installation....
ElseIf $R0 == "2000" or "XP" or "2003"
;do nothing let the installer continue
end if
From the above how would the IF syntax look in NSIS and also how do we terminate the installer?
Obviously this msgbox would need to popup before the actual first screen of the installer is shown.
Many thanks once again.
scrose
4th December 2004 21:33 UTC
Use the StrCmp command in the .onInit callback function.