You are here

Can someone check this for me

6 posts / 0 new
Last post
IllusionofDemise
Offline
Last seen: 7 years 10 months ago
Joined: 2007-08-08 08:53
Can someone check this for me

if there something wrong with this code?? because its not poping up a msg box at all and im running xp, im not good with nsis yet so i though i might have messed up the if statement or something. GetWindowsVersion is a function i found in the manual.

Section "Main"

; Windows 2000 Fix
Call GetWindowsVersion
Pop $R0
!if "$R0" = "2000"
MessageBox MB_ICONEXCLAMATION|MB_OK "windows2k"
!endif
!if "$R0" = "XP"
MessageBox MB_ICONEXCLAMATION|MB_OK "windowsXP"
!endif

SectionEnd

BuddhaChu
BuddhaChu's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2006-11-18 10:26
I'm lower than a NSIS

I'm lower than a NSIS beginner, but I don't think variables go in quotes if you want to get their value.

Try:

!if $R0 = "2000"

You are using the script from Appendix C, #5 right?

Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!

IllusionofDemise
Offline
Last seen: 7 years 10 months ago
Joined: 2007-08-08 08:53
dident work without quotes

dident work without quotes nither but i changed it a little now it works

Call GetWindowsVersion
Pop $R0
${If} "$R0" == "2000"
MessageBox MB_ICONEXCLAMATION|MB_OK "windows2k"
${EndIf}
${If} "$R0" == "XP"
MessageBox MB_ICONEXCLAMATION|MB_OK "windowsXP"
${EndIf}

wraithdu
Offline
Last seen: 10 years 9 months ago
Developer
Joined: 2007-06-27 20:22
In NSIS, if/endif works a

In NSIS, if/endif works a bit differently. The !if/!ifdef/!endif/etc. commands are compile time commands. If the conditional is not true, then the code is not compiled into the exe. Since your variables are empty your !if statement is false, and you end up with a basically empty exe.

You can do this 2 ways -

Section "Main"

Call GetWindowsVersion
Pop $R0
StrCmp $R0 "2000" 0 +2
MessageBox MB_ICONEXCLAMATION|MB_OK "windows2k"
StrCmp $R0 "XP" 0 +2
MessageBox MB_ICONEXCLAMATION|MB_OK "windowsXP"

SectionEnd

or you can add '!include logiclib.nsh' at the top of your script and do

Section "Main"

Call GetWindowsVersion
Pop $R0
${if} $R0 == "2000"
MessageBox MB_ICONEXCLAMATION|MB_OK "windows2k"
${elseif} $R0 == "XP"
MessageBox MB_ICONEXCLAMATION|MB_OK "windowsXP"
${endif}

SectionEnd

IllusionofDemise
Offline
Last seen: 7 years 10 months ago
Joined: 2007-08-08 08:53
i found the logic way in the

i found the logic way in the manual so i used that but i think ill change it to your first example. Its not going to popup a box at all its acutaly going to replace files in GnuCash to fix an issue on win2k pc's

wraithdu
Offline
Last seen: 10 years 9 months ago
Developer
Joined: 2007-06-27 20:22
In that case you'll probably

In that case you'll probably want to jump to labels instead of using relative jumps like my example (0 +2). Also note that using a relative jump to jump over a macro WILL NOT work (one of those little gotchas that isn't in the manual).

Log in or register to post comments