Skip to content
⌘ NSIS Forum Archive

SetShellVarContext with variables

7 posts

zackbuffo#

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#
🙄
${If} $0 == current
SetShellVarContext current
${Else}
SetShellVarContext all
${EndIf}
Stu
zackbuffo#
Thanks for your help, but unfortunately that doesn't do the job... 🙄


The second SetShellVarContext parameter is always used. I checked it both ways.
zackbuffo#
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...! 👍
Afrow UK#
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