Skip to content
⌘ NSIS Forum Archive

CreateShortCut problem

7 posts

hectorc#

CreateShortCut problem

I would like to create a shortcut that has as its working directory: %HOMEDRIVE%%HOMEPATH%, just like Command Prompt. What's the quickest way to do it?
jpderuiter#
You can use $PROFILE for the user's profile directory.

See chapter 4.2.3 from the NSIS manual.
hectorc#
But what if the shortcut is designed to be run by any user - using $PROFILE will hardcode it to the user installing the program no?
jpderuiter#
But what if the shortcut is designed to be run by any user - using $PROFILE will hardcode it to the user installing the program no?
Yes, you're right.

As Afrow UK said (and as is mentioned in the manual) you have to set $OUTDIR to specify the working directory:
SetOutPath "%HOMEDRIVE%%HOMEPATH%"
CreateShortcut "$DESKTOP\test.lnk" "%HOMEDRIVE%%HOMEPATH%\test.exe"
SetOutPath $INSTDIR
Afrow UK#
I assumed SetOutPath would evaluate the environment variables but it doesn't so that code works.

Stu
hectorc#
Hey wanted to wait until I was able to try this before replying, but just to confirm the advice works great, thanks!