26

We came with a scenario where we have to use Shortcut file (.lnk), which is on the desktop, to execute an application for a headless device (i.e, without manual intervention).

Is there any way to execute it from Command prompt?

20

If you use double quotes around your "long file names.lnk" and you have privvies, it will execute. Quotes are needed when spaces exist in LFN's.

E.g. "C:\Users\Sunny\Start Menu\Programs\XBMC\xbmc.lnk" opens up XBMC. The same is true for the Run box Win+R "path and filename.lnk", Enter

  • 1
    privvies? What does that mean? I searched Google on that word and the results were not related. – Hack-R Jan 24 '18 at 16:24
  • 1
    @Hack-R sorry for my slang using privvies for meaning privelges or security permissions to execute – Sunnyskyguy EE75 Jan 24 '18 at 18:19
21

START filename.lnk should do the trick

As long as there is no exe with the same name as the shortcut, you can omit the .lnk, so just START filename

  • as long as the .lnk file is in the path environment for windows it will work. otherwise not. YOu can run any service using win+R ...net start msiserver .. for example starts the Windows Installer service.. or any MS Console using run... xxx.msc (these are located in windows32 folder and in PATH) – Sunnyskyguy EE75 Jun 28 '12 at 4:33
  • 5
    Actually, in order to work I had to do START "Name of the new window" "filename.lnk". With only one arg START was just creating a new command line window named after the first parameter. See related on StackOverflow: stackoverflow.com/questions/6139365/… – Rafael Oliveira Sep 19 '13 at 15:44
2

The above solutions didn't work for me in 2017, so I experimented a bit.

It turns out that Windows (10 atleast) does make a distinction between shortcuts that link to a local path and shortcuts that are an url. What I found was that

  • local paths use the suffix .lnk
  • url-like paths have the suffix .url

So a shortcut to https://superuser.com/ would have the suffix .url while a shortcut to C:\Windows or to special locations like Control Panel would have the suffix .lnk.

If you want to execute the shortcut simply type shortcut.suffix in the cmd prompt where .suffix is the suffix according to the rule above. You must first cd to the folder containing your shortcut or enter the full path to the file. In your case

%userprofile%\Desktop\shortcut.suffix

entered into either the run dialog box (invoked via Win + R) or the cmd prompt would do the trick.

Windows and it's inconveniences.

0

First, find the location of the shortcut from which you start a cmd.exe shell. Right-click on the shortcut and choose "Properties". Look on the "General" tab and copy the "Location:" value.

Use the shortcut to start a reset window.

START "" "C:\Users\lit\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu\cmd.exe.lnk" /K CD /D "%CD%" & EXIT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.