In windows, start default app associated with file type

Discussion in 'Perl Misc' started by Philipp, Jul 6, 2007.

  1. Philipp

    Philipp Guest

    Hello
    From my perl script on windows I want to start the default viewer for
    pdf files.
    Is there an easy way of doing programatically what the OS does when you
    double-click on file with a certain type?
    ie.
    1) get file type
    2) find associated app
    3) start app with file as argument

    Thanks
    Phil
     
    Philipp, Jul 6, 2007
    #1
    1. Advertising

  2. Philipp

    Lambik Guest

    "Philipp" <> wrote in message
    news:...
    > Hello
    > From my perl script on windows I want to start the default viewer for
    > pdf files.
    > Is there an easy way of doing programatically what the OS does when you
    > double-click on file with a certain type?
    > ie.
    > 1) get file type
    > 2) find associated app
    > 3) start app with file as argument
    >

    exec "rundll32.exe url.dll, FileProtocolHandler my.pdf "
     
    Lambik, Jul 6, 2007
    #2
    1. Advertising

  3. Philipp

    Philipp Guest

    Lambik a écrit :
    > "Philipp" <> wrote in message
    > news:...
    >> Hello
    >> From my perl script on windows I want to start the default viewer for
    >> pdf files.
    >> Is there an easy way of doing programatically what the OS does when you
    >> double-click on file with a certain type?
    >> ie.
    >> 1) get file type
    >> 2) find associated app
    >> 3) start app with file as argument
    >>

    > exec "rundll32.exe url.dll, FileProtocolHandler my.pdf "


    Thanks :)
     
    Philipp, Jul 6, 2007
    #3
  4. Philipp

    Peter Wyzl Guest

    "Philipp" <> wrote in message
    news:...
    > Hello
    > From my perl script on windows I want to start the default viewer for pdf
    > files.
    > Is there an easy way of doing programatically what the OS does when you
    > double-click on file with a certain type?
    > ie.
    > 1) get file type
    > 2) find associated app
    > 3) start app with file as argument


    Let the OS handle that...

    exec 'start myfile.pdf';

    P
     
    Peter Wyzl, Jul 6, 2007
    #4
  5. Philipp

    Dr.Ruud Guest

    Petr Vileta schreef:
    > Lambik:


    >> exec "rundll32.exe url.dll, FileProtocolHandler my.pdf "

    >
    > Can you explain me what is the "FileProtocolHandler" ?
    > Please wrote 2
    > examples for my.pdf on web and on local disk.


    Hey! Use Google, or msdn:
    http://search.msdn.microsoft.com/search/?query=FileProtocolHandler

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Jul 7, 2007
    #5
  6. Philipp

    Lambik Guest

    "Petr Vileta" <> wrote in message
    news:f6n8dr$6q1$...
    > Lambik wrote:
    > > "Philipp" <> wrote in message
    > > news:...
    > >> Hello
    > >> From my perl script on windows I want to start the default viewer
    > >> for pdf files.
    > >> Is there an easy way of doing programatically what the OS does when
    > >> you double-click on file with a certain type?
    > >> ie.
    > >> 1) get file type
    > >> 2) find associated app
    > >> 3) start app with file as argument
    > >>

    > > exec "rundll32.exe url.dll, FileProtocolHandler my.pdf "

    > Can you explain me what is the "FileProtocolHandler" ? Please wrote 2
    > examples for my.pdf on web and on local disk.
    > --
    >
    > Petr Vileta, Czech republic
    > (My server rejects all messages from Yahoo and Hotmail. Send me your mail
    > from another non-spammer site please.)



    You're kidding, right? Have you even tried? my.pdf is a local file. exec
    "rundll32.exe url.dll, FileProtocolHandler
    http://tiger.la.asu.edu/Quick_Ref/perl_quickref.pdf" opens from the web.
    Sounds logical right?
     
    Lambik, Jul 7, 2007
    #6
  7. Philipp

    Lambik Guest

    "Petr Vileta" <> wrote in message
    news:f6oalh$n27$...
    > Hmm, I tried this and I found that "FileProtocolHandler" is the constant
    > defined somewhere in url.dll library. Right?
    > --


    Depends on what you call "constant". Basicly, a DLL is what we in Perl call
    a package. In contains a number of subroutines. FileProtocolHandler is such
    a subroutine. You call the program rundll.exe and ask it to open a package
    called url.dll and run its subroutine FileProtocolHandler with given
    arguments. Much as you would do in Perl like:

    perl -MURL.dll -e "FileProtocolHandler (\"
    http://tiger.la.asu.edu/Quick_Ref/perl_quickref.pdf\")"

    of course this will not work but you get my drift.
     
    Lambik, Jul 7, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    1
    Views:
    401
    Axel Dahmen
    Nov 3, 2003
  2. Replies:
    0
    Views:
    284
  3. laurent
    Replies:
    6
    Views:
    574
    Andrew Thompson
    Feb 1, 2007
  4. Neal Becker
    Replies:
    0
    Views:
    250
    Neal Becker
    Nov 12, 2006
  5. ashish
    Replies:
    0
    Views:
    147
    ashish
    Nov 21, 2012
Loading...

Share This Page