Sign in to follow this  
Followers 0
ksv247

Launching a pdf file from a script

11 posts in this topic

I've been trying to launch a manual from a script but can't seem to make it work. It's very basic stuff but I'm new to this and I don't have the time to battle with it anymore.

This works:

Func Doc()

Run("explorer.exe G:\Documentation\Help.pdf")

EndFunc

As well as this:

Func Doc()

RunWait("explorer.exe G:\Documentation\Help.pdf")

EndFunc

Of course I can't have it point to a specific letter, instead I want it to point to my scriptdir.

One of the things I've tried, that doesn't work:

Func Doc()

Run("explorer.exe @ScriptDir & "\Documentation\Help.pdf"")

EndFunc

Any ideas?

Share this post


Link to post
Share on other sites



you could look for your acrord32.exe

than this is your code

run("path\acrord32.exe " & @scriptdir & "\Documentation\Help.pdf")

have fun

usually the path is

@programfilesdir & "\adobe\acrobat *.*\reader\

I want to use explorer to determine whick application to use for opening the pdf file, since I don't want to limit myself to Acrobat/Adobe Reader.

Func HB()

Run("explorer.exe " & @ScriptDir & "\Documentation\Help.pdf")

EndFunc

Works!

Thanks so much for the help. I had a feeling it was just a small correction that needed to be made.

Could I ask for help with one more detail?

Is there a way to maximize the window (in my case Acrobat) that is opened when the pdf file is launched?

Share this post


Link to post
Share on other sites

Did you try the @SW_Maximize flag?

From the help file:

Run("Notepad.exe", "", @SW_MAXIMIZE)

Share this post


Link to post
Share on other sites

I want to use explorer to determine whick application to use for opening the pdf file, since I don't want to limit myself to Acrobat/Adobe Reader.

Func HB()

Run("explorer.exe " & @ScriptDir & "\Documentation\Help.pdf")

EndFunc

Works!

Thanks so much for the help. I had a feeling it was just a small correction that needed to be made.

Could I ask for help with one more detail?

Is there a way to maximize the window (in my case Acrobat) that is opened when the pdf file is launched?

Try this:

$file=@ScriptDir & "\Documentation\Help.pdf"

$command="C:\Windows\System32\Rundll32.exe Url,FileProtocolHandler " & $file

Run($command)

Hope it helps

Jim

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yes, I've tried the @SW_Maximize flag, and now in the way you described (?).

Func HB()

Run("explorer.exe " & @ScriptDir & "\Documentation\Help.pdf", "", @SW_MAXIMIZE)

EndFunc

Is this correct? It doesn't report an error, but it doesn't maximize the window either.

Edited by ksv247

Share this post


Link to post
Share on other sites

It works for me when I use Internet Explorer to open a URL, but then again, and someone mentioned this upthread - you're running Explorer.exe, not the Acrobat executable. Have you tried letting IE open the PDF file?

Share this post


Link to post
Share on other sites

How about letting the operating system open the pdf file based on file association. Using the "Start /Max" through a console will open your documents in a maximized window. If you use "Start /Min" then Adobe will open in a smaller window and minimized to the taskbar.

$HelpFile = @ScriptDir & "\Documentation\help.pdf"

Run(@Comspec & " /C Start /Max " & $HelpFile,"", @SW_hide)

Share this post


Link to post
Share on other sites

Yes, it worked like you said.

Func HB()

Run("C:\Program Files\Internet Explorer\iexplore.exe " & @ScriptDir & "\Documentation\Help.pdf", "", @SW_MAXIMIZE)

EndFunc

"...open the pdf file based on file association" - This was my intention using explorer, but your idea was better.

$HelpFile = @ScriptDir & "\Documentation\help.pdf"

Run(@Comspec & " /C Start /Max " & $HelpFile,"", @SW_hide)

...works as well, maximizing the window AND using the default program for pdf files, thanks to all of you for your help.

ksv

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

may be this wil work (sorry i can't try at this time):

run ("RunDLL32.EXE shell32.dll,ShellExec_RunDLL myPDFDOC.pdf")

Edited by sksbir

Share this post


Link to post
Share on other sites

I have used this before:

$helpfile=@ScriptDir & "\Documentation\Help.pdf"
    run("RunDLL32.EXE url.dll,FileProtocolHandler "&$helpfile)

RunDLL32.exe will get the application associated with the extension and lauch it.

Steve

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0