Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 23rd July 2009, 18:36   #1
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
SetShellVarContext on-the-fly ?

Can I start a section with
Quote:
SetShellVarContext current
Then change it later on (in same section) to
Quote:
SetShellVarContext all
Then change it again to
Quote:
SetShellVarContext current
?

The goal is to place some shortcuts on the Start Menu of the Administrator only, then place some items on the Start Menu of All Users, then restore ShellVarContext back to current.

I just tried that and it didn't work for me. So either there is an inherent limitation of which I didn't know or I am doing something wrong.

If the latter, any idea what could possibly go wrong in simple code like this?
PHP Code:
SetShellVarContext all
CreateShortCut 
"${D_STARTMENU}\\MyApp.lnk" "myapp.exe"
SetShellVarContext current 
nsnb is offline   Reply With Quote
Old 23rd July 2009, 19:25   #2
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 546
Did you define D_STARTMENU somewhere?
That define will not change based on SetShellVarContext.
Use $SMPROGRAMS instead (See chapter 4.2.3 in the NSIS manual)
jpderuiter is offline   Reply With Quote
Old 24th July 2009, 14:57   #3
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
Quote:
Originally posted by jpderuiter
Did you define D_STARTMENU somewhere?
Yes I did. Thank you for the tip. I changed the above to:
PHP Code:
SetShellVarContext all 
CreateShortCut 
"$SMPROGRAMS\${D_COMPANY}\${D_PRODUCT}\\MyApp.lnk" "$PROGRAMFILES\${D_COMPANY}\${D_PRODUCT}\\myapp.exe" 
SetShellVarContext current 
But this still doesn't work.

Interestingly enough, I have no such problem with SetOutPath.

Did changing SetShellVarContext on the fly ever worked for anyone?

Thanks.
nsnb is offline   Reply With Quote
Old 24th July 2009, 15:18   #4
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
Update: If I change:
PHP Code:
CreateShortCut "$SMPROGRAMS\${D_COMPANY}\${D_PRODUCT}\\MyApp.lnk" "$PROGRAMFILES\${D_COMPANY}\${D_PRODUCT}\\myapp.exe" 
To:
PHP Code:
CreateShortCut "$SMPROGRAMS\\MyApp.lnk" "$PROGRAMFILES\${D_COMPANY}\${D_PRODUCT}\\myapp.exe" 
It works.

Strange. I know that ${D_COMPANY} and ${D_PRODUCT} are defined and valid. Why is it behaving like this?
nsnb is offline   Reply With Quote
Old 24th July 2009, 15:31   #5
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
Problem solved.

What was missing is the CreateDirectory statement before the CreateShortCut:
PHP Code:
CreateDirectory "$SMPROGRAMS\${D_COMPANY}\${D_PRODUCT}" 
jpderuiter, thank you again for the clue that led to the solution.
nsnb is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump