Menu entry to execute a program with parameters?

Product Compare Forums Multi-Edit Support Menu entry to execute a program with parameters?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #3002
    Bret Sutton

    I can create a menu entry to open a specific PDF file by checking type Program and using, for example, this command:
    [code:1oo2w2kl]"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "C:\Hoohah\Doc\Hoohah.pdf"[/code:1oo2w2kl]
    I can pass command-line options to the reader by checking type Program and using this command:
    [code:1oo2w2kl]"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /A "page=586=OpenActions" "C:\Hoohah\Doc\Hoohah.pdf"[/code:1oo2w2kl]
    (These two have the unfortunate effect of leaving a Multi-Edit dialog box up. I can just press the "Bypass" button, but it’s a slight nuisance.)

    If I have a viewer identified in Windows for PDF files, I can check type Help_file and use just the filename:
    (Note that I cannot use quotes, as Multi-Edit appears to take the trailing quote as part of the extension, and will not find a viewer for that extension. And I must use the short-format name if the long-format name contains any spaces. :( )

    Alternatively, I could avoid mentioning the viewer directly (which is a good thing!) by coding it as type Program with this command:
    [code:1oo2w2kl]<comspec> /c start "" "C:\Hoohah\Doc\Hoohah.pdf"[/code:1oo2w2kl]
    And this has the added benefit of permitting a long filename.

    But how do I code the second example, where I’m passing options to the viewer, to avoid mentioning the viewer directly? I have had no luck with that.

    Clay Martin

    Hi Bret,
    Have you tried the long file name, <LFN> meta command within the internal Muti-Edit command line for the menu entry?

    Also these articles may be of use. … -open-with … with-start


    Bret Sutton

    The only way I found to do what I want is to modify the registry.

    The .pdf extension is associated with the AcroExch.Document.11 filetype – see HKEY_CLASSES_ROOT\.pdf\(Default). I found that the entry for HKEY_CLASSES_ROOT\AcroExch.Document.11\shell has both an Open\command and a Read\command. For both, the (Default) key value was
    [code:16iz2mn2]"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "%1"[/code:16iz2mn2]
    Windows’ file association rules want the filename to come first on the command line; Acrobat Reader wants the options to come first. So I tried changing the value for the Open\command\(Default) to
    [code:16iz2mn2]"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" %2 %3 %4 %5 %6 %7 %8 %9 "%1"[/code:16iz2mn2]
    It didn’t work for me. So I reset it and tried the same modification to the Read\command\(Default) value. That did the trick.

    So: In the Multi-Edit menu entry for help, where I want to go to a specific page in a PDF file, I can set the type to Program, and specify a command line like this:
    [code:16iz2mn2]<comspec> /c start "" "\\our_documentation_server\HPDoc\30391-90012.pdf" /A "page=544=OpenActions"[/code:16iz2mn2]
    The way file associations work, the target filename must be the first parameter here, and the options must trail. Since Acrobat Reader expects the options first, the registry change I made will reverse this order and keep Reader happy.

    If I want simply to open a PDF file without going to a specific page, I can code it as in my last example from my first message, and that still works.

    This registry change appears not to have affected the opening of PDF files outside Multi-Edit, either from a command line or by double-clicking a PDF file icon. In those cases, it will generate a command with 9 leading spaces before the filename; but they’re ignored by the command processor. The use of %2 through %9 is a kludge – I know I’ll never specify more than 8 options, and there’s no way in Windows to say "all parms except parm 1" unless I use some convoluted command-line logic that I sure didn’t want to introduce here.

    It’s unfortunate that a registry change was required, as this means one more step in the Multi-Edit installation process for our developers. But I couldn’t figure out another way to get those parms to Acrobat Reader in the correct order, yet still satisfy the requirements of Windows’ file-association processing.

    Clay Martin

    Hi Bret,
    Thanks for all the info!


Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.