Archive: CreateShortCut problem


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?


You can use $PROFILE for the user's profile directory.

See chapter 4.2.3 from the NSIS manual.


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?


Try setting $OUTDIR to "%HOMEDRIVE%%HOMEPATH%" with StrCpy.

Stu


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

I assumed SetOutPath would evaluate the environment variables but it doesn't so that code works.

Stu


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