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
But when I run the same command from the NSISmklink "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.nsExec::Exec 'mklink "D:\desktop\test.lnk" "d:\test\test.exe"'
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.