Why do some shortcuts not support editing the command line and other properties?

Ben L observed that some shortcuts do not permit the command line and other options to be edited. "Where is this feature controlled? Is there a way to override this mode?" This question is echoed by "Anonymous (Mosquito buzzing around)" (and don't think we don't know who you are), who in a huge laundry list of questions adds, "Why does the Game Explorer limit customizing command line, target, etc?"

These questions are looking at the situation backwards. The issue is not "Why do these shortcuts block editing the command line?" The issue is "Why do some shortcuts allow editing the command line?"

Recall that shortcuts are references to objects in the shell namespace. Shell namespace objects are abstract. Some of them refer to files, but others refer to non-file objects, like control panels, printers, and dial-up networking connectoids. And in the abstract, these objects support verbs like Open and Rename. But there is no requirement that a shell namespace object support "Run with command line argument".

If you have a shortcut to an executable, then the LNK file handler says, "Okay, this is a special case. Executables support command line arguments, so I will run the executable with the command line arguments set by the IShell­Link::Set­Arguments method.

Note that the shortcut target and arguments are separate properties. The LNK file property sheet hides this from you by calling IShell­Link::Get­Path and IShell­Link::Get­Arguments, then taking the two strings and combining them into a single Target field for display. When you save the changes, the LNK file property sheet takes the Target, figures out which part is the executable and which part is the arguments, and calls IShell­Link::Set­Path and IShell­Link::Set­Arguments on the two parts.

In other words, the command line is all a ruse.

This special action is performed only for executable targets, because those are the only things that accept arguments. If you create a shortcut to a control panel, you'll find that the Target is not editable. If you create a shortcut to a printer, you'll find that the Target is not editable. If you create a shortcut to a dial-up networking connectoid, you'll find that the Target is not editable. Having a non-editable command line is the normal case. The file system is the weirdo.

Shortcuts to advertise applications and shortcuts to items in the Games folder are not shortcuts to executables. They are shortcuts into the shell namespace for various types of virtual data. An advertised application is a shell namespace object that represents "an installed application". It is not a pointer directly to the executable, but rather a reference to an entry in the MSI database, which in turn contains information about how to install the program, repair it, update it, and run it. The shell doesn't even know what the command line is. To launch an advertised shortcut, the shell asks the MSI database for the command line, and it then executes that command line that MSI returns. The value set by IShell­Link::Set­Arguments never enters the picture. Similarly, the entries in the Games Folder are not executables; they are entries in the games database.

I can see how this can be confusing, because when you click on these shortcuts, a program runs, but these shortcuts are not shortcuts directly to programs. As a result, the code that takes a Target and Arguments and combines them into a command line does not get a chance to run.

Comments (27)
  1. Anonymous says:

    Good explaination, but I do wonder why whoever designed all this didn't stop and think "surely there has to be a better way than this".

    It all just seems overcomplicated for simply running a program.

    [The complicated part is supporting things like "running a program that hasn't been installed yet" or "running a program whose location can change at any time" or "updating a program before running it." It's the standard "wrapper object" pattern. This is actually much less complicated than "add custom behavior scattered all over the system" and dealing with the compatibility issues of apps which launch shortcuts and don't realize "the SLDF_NOTJUSTAPROGRAM flag is set, I need to call Function X before executing the command line.") -Raymond]
  2. Anonymous says:

    JB, it is a pretty good way to do it. The mechanism (verbs on shell objects) was already in place, and it allows Windows Installer to create shortcuts to things that aren't installed (yet).

  3. Anonymous says:

    So how do you go about setting command line arguments for items in the games database or MSI database? Ultimately they are executable that do have arguments, is the place for customization just pushed further down the stack?

  4. I'm curious: How frequently are there programs whose location can change at any time? I'm sure at least some exist, I've just never noticed any such programs, personally. Is this to cover the case of "allowing the shell to use program X's shortcuts after it upgrades to a new version and changes its .exe name for some reason (such as marketing rebranding the software)"?

    [You didn't notice that Winword.exe moved from the Office14 directory to the Office15 directory? -Raymond]
  5. DWalker59 says:

    "If you have a shortcut to an executable, then the LNK file handler says, "Okay, this is a special case….""  But most shortcuts are shortcuts to executables (when they are not shortcuts to documents; and on those, we know that we can't edit the command line).

    The shortcuts to Office applications (probably via the shell namespace objects) that would SEEM to be shortcuts to executables are strange, when they don't allow you to edit the command line.  So I see the OP's confusion.

  6. WndSks says:

    There is no real reason for the shell to prevent you from changing the icon, its just by design. With a little bit of work it would be possible to support a custom argument string as well (MSI app path + lnk arguments)

    When a LNK is blessed with a Darwin(MSI) datablock the shell does extra work to invoke the shortcut but before it gets to this point it probably needs to know the icon and a list of verbs (IContextMenu).

    The normal Path/Pidl/Icon entries in the LNK point to a file in %windir%Installer{guid} or %appdata%MicrosoftInstaller{guid} (So calling IShellLink::GetPath on a MSI shortcut does work). Why the icon is stored this way is not a big surprise since the application itself might not be installed yet. The path and/or pidl is another story, at least on older versions of Windows the file in the Installer{guid} directory has to have the same extension as the target (.exe, .chm etc) so that the shell can build the list of verbs by pretending that this file is the real target.

    Back in the old shell days this information was not stored in a LNK datablock, the Logo3 or Darwind id was stored directly in the path in a special format: IShellLink->SetPath("::{DarwinOrLogo3Guid}:%appid%::c:pathtorealtarget.exe") (Google blesslnk)

  7. Using this indirection might have been very clever and solved a problem for someone, somewhere. But it does make the Games folder virtually useless. Quite a few games have special options to suppress playing the startup videos, enable unusual video modes, turn on cheats or 3rd-party mod loading. Add to that the older games that don't have Game folder shortcuts and I don't think I've launched a game from the Game folder in months.

    I don't think Microsoft involved any actual game players in the design. :-)

  8. xpclient says:

    That question "Why does the Game Explorer limit customizing command line, target, etc?" was in reference to Windows 7 which unnecessarily restricts that from the shortcut's Properties vs Vista which allowed that. And the answer expected wasn't why doesn't it technically but more like "which moron took that decision to restrict game parameters and why". Neither can compatibility mode be set for older game shortcuts in Windows 7's Game Explorer. You have to create a shortcut outside and then paste it.

    [This is your final warning re violation of the ground rules. No disrespectful behavior, and the rule explicitly calls out the word "moron". -Raymond]
  9. xpclient says:

    Oh it wasn't intentional. Just out of frustration. Anyways, I will try to keep my cool. Wish we would give warnings to Microsoft for intentionally removing features.

  10. chentiangemalc says:

    I think this whole method of LNK files is mostly good and the support for advertised shortcuts great. However it does throw people. My main wish here is that there is some UI change in Properties of the advertised shortcut – i.e. if we could see the command line (non-editable) as queried from Windows Installer, and some note why this shortcut cannot be changed. Of course even with such a notice I know most people won't read it…so probably can't win either way there.

    As for the Games Explorer interface, don't worry people, it's gone in Windows 8. We just have "Games" With XP going out of support soon maybe XPClient can upgrade to Windows 8 and swipe into a more productive lifestyle than trolling MS blogs.

    [The trick is that getting the command line may trigger an update/install! So you have "I tried to view the Properties of this shortcut, and it installed an app!" -Raymond]
  11. Entegy says:

    I thought you gave up and left Windows for OS X xpclient?

  12. Anonymous says:

    [The trick is that getting the command line may trigger an update/install! So you have "I tried to view the Properties of this shortcut, and it installed an app!" -Raymond]

    NOW we finally get a rational explanation. Still should be able to change the icon. Oh wait, yes we can.

  13. [You didn't notice that Winword.exe moved from the Office14 directory to the Office15 directory? -Raymond]

    I sure didn't, and in retrospect that makes me a happy end-user.

    @John Ludlow: I'm not sure if there's an appreciable difference between "install-time" and "any time", from the OS's perspective. The installer/updater is the one that has to check whether the application is in use before writing to application files or updating system settings that the application might be using. And certainly, updating Contoso2012 shouldn't be a blocking operation for anything more than what the Contoso installer needs.

  14. Worst part about those proxy shortcuts is that they don't accept drag-n-drop.

  15. Anonymous says:

    @alegr1: If reading this blog and playing with Windows has taught me anything, it's that those weird proxy shortcuts almost certainly DO accept drag-and-drop. You just haven't worked out what interface your proxy stub needs to implement in order to get the functionality to suddenly work :)

  16. John Ludlow says:

    "[You didn't notice that Winword.exe moved from the Office14 directory to the Office15 directory? -Raymond]"

    Well, that's not really at *any time*, that's at *install-time* (a special, magical time where pretty much anything can and will happen), and it would make sense for the install to be responsible for updating the .lnk.

    It's a good point that what happens when you double click a link is not always as simple as runing a command line, though I think it usually is, even for control panel items. For example, the WDS Indexing Options dialog seems to be implemented as the following command:

    "C:WindowsSystem32rundll32.exe" C:WindowsSystem32shell32.dll,Control_RunDLL C:WindowsSystem32srchadmin.dll

    I get why the Game Explorer exists (an interface to your gaming library, where you can see the cover art etc just like you'd expect in most media player applications).  However, I don't think it's quite worked out. Maybe if you could change the items that were visible in there, and change launch parameters, etc, then some of the issues would be resolved.

    [For IT-deployed applications, the client machine doesn't have an explicit "install-time". All applications are install-on-demand. To the end user, it just seems that Word is a little slower to launch than usual today, and hey look it's Office 2013. -Raymond]
  17. xpclient says:

    @Entegy, Sure I plan to. Not right away. Everything costs money.

  18. Drak says:

    @XPClient: $40 isn't all that much. (At least that's what it seems to cost now (up to Jan 31st). Just look on the Microsoft site).

  19. Anonymous says:

    "Anonymous (Mosquito buzzing around)' (and don't think we don't know who you are),"


    I see that this sort of self-aggrandisement in your other posts as well, so I have a question. Why do you come off as someone with their nose in the air? Is it because you are affiliated with Microsoft?

    Just because you are employed doesn't make you any less of a person, so why not treat your fellow visitors with a little more respect, instead of serving them a pompous attitude? They're people too.

    [You must be new here. (I typically wait until a visitor is rude before I start being rude back. In this case, I knew who it was because this person asks the same question over and over and decided to change his name temporarily to make it look like it was a different person asking.) -Raymond]
  20. Anonymous says:

    Presumably this was why KB article 210565 was written. (But of course this doesn't help you if your version of Word gets upgraded after you've created the shortcut…)

  21. Thanks for the explanation. Using shortcuts as program advertisement before installation, it seems that this isn't common knowledge or practice outside of the Office team from my observation. I do recall some painful times when an msi installation seemed to run instead instead of the already installed Word for no apparent reason year ago.

  22. DWalker59 says:

    Calling someone a moron isn't usually done out of frustration.  When I am frustrated by someone else's decision in a technical matter, my first thought is not to insult their overall intelligence.  It shows a clear lack of respect.  Just because someone else didn't make the same decision you did, that doesn't mean they are stupid.

  23. Anonymous says:

    [You didn't notice that Winword.exe moved from the Office14 directory to the Office15 directory? -Raymond]

    Doesn't this defeat the purpose of having an Office14 and Office15 directory (that is, give the user the ability to choose which version to run) ?

    [Presumably if you did a side-by-side install, then both would remain. The redirection happens in the case of a centrally-deployed silent upgrade install. -Raymond]
  24. Anonymous says:

    But you are totally missing the point. xpclient makes a very valid point although his tone is usually offensive. Microsoft cheats users by slyly omitting features. Raymond writes as though whatever decisions they took are the best and customers are always wrong. From what I read on xpclient's blog, he works on Classic Shell, so he really is already helping millions of people from Microsoft's wrongs. It is a very famous FOSS project. As for blog rules, they vary from person to person. Just because Raymond is tolerant of his offensive tone doesn't mean he has to be tolerant of whatever you said on his blog. I see his complaints as more of a helpless rant because of him unable to do anything against the systematic dumbing down of Windows in each iteration. Frankly, I get his frustration too. MS have a long history of burning their users with ridiculous changes and then telling them to adapt to them. Although xpclient could change his tone and be more reasonable.

  25. Anonymous says:

    @@VVB: I'm not sure that I'd agree that Raymond says that all the decisions made at Microsoft are "the best"; he usually discusses what decisions were made and sometimes the rationale behind them. I'd call what Raymond does "reporting" and it is one of the reasons why I make a point to read his blog. (Of course, the large number of really useful technical articles that he writes helps too!)

  26. Anonymous says:

    @Ian: The alacrity you showed in defending xpclient's 'honor' is so misplaced I don't even know where to begin. In fact, I believe Ray has been *extremely* patient with him so far. If it was me, I'd have banned him from my blog years ago. Also, he has the temerity to think he can come here and abuse people left and right, but seems to be completely intolerant of any criticism directed at him. When he made the grand announcement on his blog that he was dumping Windows and moving to Apple, I left a simple non-abusive comment to the effect that there were many who would heave a sigh of relief that we (hopefully) wouldn't have to read his posts ever again. Guess what, the comment disappeared within a few minutes. Frankly speaking, I agree with some of his comments regarding reduced functionality in certain areas in Windows 7 vs. XP (never used Vista). However, people like him with a one-track mind who offer nothing constructive (inflated claims of being a "UX consultant" to some program do *not* count) and instead are obsessed with directing a *constant* barrage of negative criticism towards those who do actually do good work get on one's nerves really, *really* quickly. Any support such people might have otherwise garnered is very quickly eroded thanks to the interminable whining and vitriolic attitude, while themselves being super-prickly when the spotlight's on them for a change. I would actually have some respect for the guy if he had bothered to use his immense "UX expertise" (what are his academic credentials exactly in this field?) to help out many FOSS projects that could do with some spit and polish. Learn to do something constructive for a change and be a role model (like Ray) and *then* you can hope that others follow suit, rather than doing nothing except haranguing others, stamping your feet, holding your breath till you turn blue in the face and making unreasonable demands.

  27. Anonymous says:

    Does anybody knows a program (ideally a shell extension replacing/extending the regular shortcut property sheet) which allows me to view (presumably also edit) all the data stored in a shortcut?

Comments are closed.