View Single Post
Old 7th April 2018, 11:52   #1
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
NSIS creating app shortcut in C:\users\..\desktop even if desktop path is different

I have an application and I use NSIS as the wrapper for distributing the application. In the application installation process I am trying to create shortcut for my application in desktop. For the normal users the application shortcut is created in their desktop who has the desktop in the path “C:\users\user_name\desktop”.

But, the NSIS fails to create the application shortcut for the users who set the desktop to different path using the registry for example in “D:\Desktop”, instead of creating the shortcut in the “D:\Desktop” it is created in the path “C:\users\user_name\desktop”. While creating the shortcut I used $DESKTOP variable to access the desktop path.

I even tried creating the shortcut by giving the static path (Ex: D:\MyDesktop) in NSIS script but surprisingly the shortcut is created in the path “C:\Users\user_name\MyDesktop”.
Also, if I give the static path as D:\Desktop for createshortcut, it creates the shortcut in the path “C:\users\user_name\desktop” instead of D drive path.

If I add, a messagebox to display $DESKTOP, it gives the proper path as D:\Desktop. Also, if I try to extract the file to desktop usin command Setoutpath $DESKTOP & File “somefile”, it is properly extracted to D:\Desktop only. So, the problem is related to creating shortcut only. All others are working.

For checking purpose I created the shortcut using the following command in the cmd and it worked fine
mklink "D:\desktop\test.lnk" "d:\test\test.exe”

But when I run the same command from the NSIS
nsExec::Exec 'mklink "D:\desktop\test.lnk" "d:\test\test.exe"'

the NSIS created the shortcut in “C:\Users\user_name\Desktop\test.lnk”. I am not able to find the root cause of the error and solve it.

This error does not exist in all PCs with the desktop in different than C:\users. In some PCs, it is working fine and in some, it is giving this type of error. There is no problem for creating shortcut in start menu. Only for Desktop shortcuts is creating problem.
winman2004 is offline   Reply With Quote