voyteckst
30th October 2006 22:10 UTC
Files and registry entries dependent from Windows ver
Hi, I want to write an installer which can install different files and registry entries dependent from windows version. I know how to display/check Windows version, but completely don't know where to put the if's code to do what I want. Can someone help me with it?
deguix
31st October 2006 03:16 UTC
This depends on how you are checking the version. If you are using the "Get Windows version" function from the documentation, for example, you could do the following:
${If} $variable == "XP"
;code gets executed if Windows XP is installed.
${ElseIf} $variable == "2003"
;...
${Else}
;code gets executed if any other Windows version is installed.
${EndIf}
or use the variant:
${Switch} $variable
${Case} "XP"
;code gets executed if Windows XP is installed.
${Break}
${Case} "2003"
;...
${Break}
${Default}
;code gets executed if any other Windows version is installed.
${Break}
${EndSwitch}
If you are checking the exact version (unlikely), you could use the ${VersionCompare} instruction macro from the WordFunc.nsh header file; as indicated in the
documentation.
voyteckst
31st October 2006 06:00 UTC
Thanks. So I put this example code in each section, right?
${If} $R2 == "98"
${OrIf} $R2 == "Me"
;do something
${ElseIf} $R2 == "2000"
${OrIf} $R2 == "XP"
${OrIf} $R2 == "2003"
;do something
${Else}
;something
${EndIf}
kichik
31st October 2006 09:44 UTC
You can use the new WinVer.nsh header file in 2.21. With it, you won't need to update the code every time a new version of Windows comes out.
!include WinVer.nsh
${If} ${IsNT}
${If} ${AtLeastWin2000}
# do something
${EndIf}
${Else}
${If} ${AtLeastWin98}
# do something
${EndIf}
${EndIf}
voyteckst
31st October 2006 15:52 UTC
Thanks, and what with the second question? Simply in each section create os version corresponded conditional statements and it will work?
kichik
31st October 2006 17:49 UTC
Yeah, that should work.