Opening a PDF File with Arguments

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
danrg7
Posts: 10
Joined: Fri May 25, 2007 7:42 pm

Opening a PDF File with Arguments

Post by danrg7 » Mon Jul 27, 2009 10:05 pm

I am familiar with the launch document command which is great for opening pdf's, but I would like to open a pdf file to a specific location, and that requires arguments. Can I pass arguments to the launch document command? Or is there a way to look up what application would launch that file and then use that from the command line?
Dan

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Mon Jul 27, 2009 11:00 pm

I believe the "launch document" command would have exactly the same effect as double-clicking a file - ie it would open that file with the appropriately registered application. I don't think parameters can be passed.
However you can easily start an application and pass it the arguments you need using the shell commands.

Something like

Code: Select all

set the hideConsoleWindows to true
   get shell ("start" && quote & quote && quote & "theFileName.pdf" & quote && quote & "argument1" & quote && quote & "argument2" & quote)
   --the "extra" quotes at the beginning are because the first quoted parameter passed to "start" 
   --are used as the console window title - so there's an empty "title" parameter there.
   --You may find you need to wrap the whole lot in another set of quotes, but that will be a case
   --of your own experimentation to tell you whether it's needed.

danrg7
Posts: 10
Joined: Fri May 25, 2007 7:42 pm

Post by danrg7 » Tue Jul 28, 2009 6:43 pm

The problem is that I need to pass arguments to the pdf reader executable. To do this I got the command to run for pdf files from the registry:

Code: Select all

put queryRegistry("HKEY_CLASSES_ROOT\AcroExch.Document\Shell\Open\Command\") into pdfcmd
And then I appended the parameters to pdfcmd and ran that in the shell.
Dan

Post Reply

Return to “Windows”