Archive: NSIS CreateShortCut DESKTOP


NSIS CreateShortCut DESKTOP
Hello All,

I am trying to set up a NSIS script for an application and have 2 problems that I hope you will help me with.

1. I want to create a desktop shortcut to an application, but also I need to be able to change the working directory to the directory that the application is currently located in from the shortcut.

I am currently using a batch file but think that I sould be able to somehow specify the working directory from the NSIS shortcut command, right?

Also, my desktop and quick launch shortcuts are not being created for some reason as well.

2. This is a similar problem as above but from the start menu items.

Thanks,
Lonnie


It would be helpful to post the script.


Thanks for replying, but in re-reading the docs I was able to solve the problem....

Thanks again,
lonnie


Sharing is what it's about.
Thanks for sharing!

:- bb


Hi Lonnie,

I had the same problem and it would have been nice if you'd told us where you found the answer so that others can benefit from it.

I found a solution too which is detailed at http://www.seas.gwu.edu/~simhaweb/ja...r/install.html

The relevant part is:

How does a java application find all the classes that it uses? (Setting the working directory)

In almost all operating systems, a call can be made to an executable file from anywhere. Suppose you have MyApplication.exe placed in C:\TestExe\. To run MyApplication.exe, you typically would go to the TestExe directory and then call:

C:\TextExe\> MyApplication

However, we could be in a folder like C:\Another_Folder\Inside_yet_another_folder\ and still be able to execute MyApplication.exe. How? Like this:

C:\Another_Folder\Inside_yet_another_folder\> C:\TestExe\MyApplication

This kind of example works in Unix as well (of course, the directories wouldn't be starting with "C:". What is different about these two program calls. The working directory of each application is different. In the first example, the working directory is C:\TestExe because that is where we launched the application from. In the second example the working directory is C:\Another_Folder\Inside_yet_another_folder . The working directory is the directory from which the application is launched. As you have seen, it doesn't necessarily have to be the directory where the program is installed.

Go to your start menu, and under programs, find a shortcut. Right-click on this shortcut and now in the new window, look at the text box labelled "Start In:". That is the working directory of that application.

How do we make sure that the working directory in our shortcuts are where we want them to be? There is no parameter to set for that in the CreateShortcut function in NSIS. Look back to the first example where we created start menu shortcuts. Notice that we have set an Outpath for copying files. This Outpath is ALSO set as the working directory for every shortcut that is created after that SetOutPath command. If you would like to change the working directory of a shortcut, then simply change the OutPath to what you would like, create the shortcut, and then, if you want, change the OutPath back.

Hope that helps.

-Chris


I just bumped into this problem myself, but lo I have a solution, here is an example:

CreateDirectory "$SMPROGRAMS\$StartMenuGroup"
SetOutPath $INSTDIR
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" $INSTDIR\App.exe
SetOutPath $SMPROGRAMS\$StartMenuGroup
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninst.exe

It says under CreateShortCut:

$OUTDIR is used for the working directory. You can change it by using SetOutPath before creating the Shortcut.
Stu