Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 7th April 2018, 11:52   #1
winman2004
Member
 
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
code:
mklink "D:\desktop\test.lnk" "d:\test\test.exe”

But when I run the same command from the NSIS
code:
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
Old 7th April 2018, 12:42   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,869
Do you have RequestExecutionLevel in your script?

mklink creates symlinks and hardlinks. Are you talking about symlinks or shortcuts (CreateShortcut / .lnk)?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 9th April 2018, 06:21   #3
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
I want .lnk file as part of our program NSIS setup installation
winman2004 is offline   Reply With Quote
Old 17th April 2018, 05:37   #4
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
@Anders, yes i have RequestExecutionLevel in my script and i also have "SetShellVarContext all". For creating the shortcut i used the code
CreateShortCut "$DESKTOP\test.lnk" "d:\test\test.exe"
but still the shortcut is not created where it supposed to create
winman2004 is offline   Reply With Quote
Old 17th April 2018, 18:12   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,869
Quote:
Originally Posted by winman2004 View Post
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.
NSIS does not modify the .lnk path in any way, it is passed directly to IShellLink/IPersistFile.

Which version of Windows is this happening on?

For "SetShellVarContext all" to work you also need "RequestExecutionLevel admin".

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 18th April 2018, 09:12   #6
winman2004
Member
 
Join Date: Nov 2009
Location: Mangalore-Karnataka-India
Posts: 87
currently i am getting this error in only windows 10. I have the "RequestExecutionLevel admin" in my NSIS script.
winman2004 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Tags
desktop, nsis, shortcut, windows

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump