Announcement

Collapse
No announcement yet.

NSIS creating app shortcut in C:\users\..\desktop even if desktop path is different

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    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

    Comment


    • #3
      I want .lnk file as part of our program NSIS setup installation

      Comment


      • #4
        @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

        Comment


        • #5
          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

          Comment


          • #6
            currently i am getting this error in only windows 10. I have the "RequestExecutionLevel admin" in my NSIS script.

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎