Launching an LNK from a Context Menu Item


  1. Posts : 745
    Windows 10/11
       #1

    Launching an LNK from a Context Menu Item


    Today, while experimenting with context menu entries, I tried running a shortcut (.lnk file) directly from a context menu item (i.e. Explorer right-click menu). The result was interesting:
    Launching an LNK from a Context Menu Item-appcantrun.png

    Yes, of course I know that I can run the exe directly and avoid the .lnk altogether, but this something that I may leverage in a tool I'm working on. Maybe.

    The obvious answer would seem to be to prefix the .lnk path with explorer.exe. That works if it's a .lnk path only. But if I'm also trying to pass the item being right-clicked using %1 or %v, then Explorer doesn't know what to do and just opens Documents.

    The best solution I found so far is to prefix the .lnk path with cmd /c start. That works for all .lnk paths with or without a %1 or %v variable being passed. But it does briefly flash a cmd window, which is not desirable.

    I also know that I can use an external VBScript or JSCript file, but I'm looking for something that will not require additional scripts.
      My Computer


  2. Posts : 43,020
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2
      My Computers


  3. Posts : 745
    Windows 10/11
    Thread Starter
       #3

    PowerShell will also flash a console window, so it offers no advantage over using cmd /c start. Anyhow, I decided I'm not going to use shortcuts for my project because they don't support relative paths. I'll mark this as solved, even though it's technically "no longer needed".
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:18.
Find Us




Windows 10 Forums