Archive: CreateShortCut bug - $WORKDIR is needed


Hi:

Have a look at this scripts which setup start menu links:
...
SetOutPath $SMPROGRAMS\MyApp
CreateShortCut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe"
...

After installation, MyApp.exe may not work from the Start menu, since the working directory is pointing to $SMPROGRAMS, that was the $OUTDIR, not the $INSTDIR.

IMHO this is a not healthy logic, because most app will not be happy to work in $SMPROGRAMS.

So it maybe helpful to set a $WORKDIR for CreateShortCut instruction to do it right.

P.S. Interestingly, this instruction do things right when creating desktop shortcuts, the working directory was set to $INSTDIR...


hi

If you use SetOutPath in adiition with CreateShortCut then SetOutPath sets the workingdirectory, nothing else.

Simply set it to $INSTDIR and everything should work fine.

try it like this


SetOutPath - ;($INSTDIR)
CreateShortCut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe"


cu yzo

thanks yazno,

but I'm afraid that the CreateShortCut behaves not as what you described, I tried your suggested code, but the installer just outputs alotof error msg like this:
--------------------------------------------------------------------------------
Error creating shortcut: C:\Windows\Start Menu\Programs\MyApp\MyApp.lnk
--------------------------------------------------------------------------------

I found if without issue this line first:
SetOutPath $SMPROGRAMS
all the following $SMPROGRAMS\*.lnk shortcuts always failed,
but with this line, MyApp.exe shortcut's working directory will also be the $SMPROGRAMS.
do we have a dilemma here?

Pardon me for mentioning this again, the following desktop shortcut script works:
--------------------------------------------------------------------------------
SetOutPath $INSTDIR
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp\MyApp.exe"
--------------------------------------------------------------------------------
the exe working directory was set to $INSTDIR accurately, but the same logic above won't apply to $SMPROGRAMS shortcut setting.

maybe it's the time to re-think why the CreateShortCut instruction behave this way... :)


hi,

no need to re-think this.

you have to create the MyApp directory in the $SMPROGRAMS folder _before_ creating the Shortcut!

sorry, i thought you knew that.

so this should work:


SetOutPath -
CreateDirectory $SMPROGRAMS\MyApp
CreateShortCut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe"


cu yzo

My point, exactly.

For some reason, on certain systems, the directory needs to be created. I think this is a bug, most definitely, since on some systems this isn't required.