zackbuffo
29th September 2011 08:48 UTC
SetShellVarContext with variables
I'm struggling with variables again.
I want to read "all useres" or "current user" out of an ini-file, but it doesn't work this way:
Section "install"
ReadINIStr $0 $INSTDIR/Setup.ini USER AUTOSTART
SetShellVarContext "$0"
CreateShortCut "$SMPROGRAMS\Startup\App.lnk" "$INSTDIR\App.exe"
SectionEnd
I tried $0 with and without double quotes. It doesn't compile.
First I thought SetShellVarContext is just working on compiletime, but as I used "all" or "current" instead of $0 within a Section, there were no problems.
Any ideas?
Afrow UK
29th September 2011 09:17 UTC
Use an If?
Stu
zackbuffo
29th September 2011 09:27 UTC
To do what?
Afrow UK
29th September 2011 10:07 UTC
:rolleyes:
${If} $0 == current
SetShellVarContext current
${Else}
SetShellVarContext all
${EndIf}
Stu
zackbuffo
29th September 2011 11:51 UTC
Thanks for your help, but unfortunately that doesn't do the job... :rolleyes:
The second SetShellVarContext parameter is always used. I checked it both ways.
zackbuffo
29th September 2011 13:11 UTC
Solved!
@Afrow UK: I guess your code didn't work for me, because I don't have LogicLib installed...?
I solved the problem with the StrCmp instruction. That's basically what you suggested:
ReadINIStr $0 $INSTDIR\Setup.ini USER AUTOSTART
StrCmp $0 "current" 0 else
SetShellVarContext current
Goto endStrCmp
else:
SetShellVarContext all
endStrCmp:
CreateShortCut "$SMPROGRAMS\Startup\App.lnk" "$INSTDIR\App.exe"
Thanks for the hint...! :up:
Afrow UK
29th September 2011 16:43 UTC
You do have LogicLib; it is included with NSIS. If you aren't using MUI2 (which you should be) then just !include LogicLib.nsh.
Edit: Actually your code wouldn't have compiled if you didn't include LogicLib so not sure what the problem was there.
Stu