Running a script as if it were a Windows executable?

Discussion in 'Perl Misc' started by Alek Trishan, Mar 9, 2014.

  1. Alek Trishan

    Alek Trishan Guest

    I have a perl script that I can run by opening a command window and typing
    perl.exe myscript.pl

    I would like to create an "executable" file (but not a desktop shortcut)
    that, when clicked on, would execute that command.

    Can anyone help?

    Thanks.
     
    Alek Trishan, Mar 9, 2014
    #1
    1. Advertising

  2. Alek Trishan

    John Bokma Guest

    Alek Trishan <> writes:

    > I have a perl script that I can run by opening a command window and typing
    > perl.exe myscript.pl
    >
    > I would like to create an "executable" file (but not a desktop
    > shortcut) that, when clicked on, would execute that command.
    >
    > Can anyone help?


    PAR::packer has the pp tool which packs perl (the exe) and your script
    and modules into a single exe file. This file you can also copy to a
    different computer and run. Since it includes perl the resulting exe is
    quite large (over 1 MB).

    No idea if there's something better, but I've used pp for years and most
    of the time it just works.

    --
    John Bokma j3b

    Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
    Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
     
    John Bokma, Mar 9, 2014
    #2
    1. Advertising

  3. Alek Trishan

    Alek Trishan Guest

    On 3/8/2014 10:26 PM, Jürgen Exner wrote:
    > Alek Trishan <> wrote:
    >> I have a perl script that I can run by opening a command window and typing
    >> perl.exe myscript.pl
    >>
    >> I would like to create an "executable" file (but not a desktop shortcut)
    >> that, when clicked on, would execute that command.

    >
    > Very easy. You just need to associate the file type *.pl with your Perl
    > interpreter. Normally the Setup process for your Perl system will do
    > that automatically.
    > But if the association is broken, then right-click on a *.pl file,
    > select "Open With" and re-create the association to the Perl
    > interpreter.


    Brilliant!!! Thanks so much. :)
     
    Alek Trishan, Mar 9, 2014
    #3
  4. Alek Trishan

    Scott Bryce Guest

    On 3/8/2014 5:23 PM, Alek Trishan wrote:
    > I have a perl script that I can run by opening a command window and
    > typing perl.exe myscript.pl
    >
    > I would like to create an "executable" file (but not a desktop
    > shortcut) that, when clicked on, would execute that command.


    Windows still supports batch files, does it not?
     
    Scott Bryce, Mar 10, 2014
    #4
  5. Alek Trishan

    Alek Trishan Guest

    On 3/9/2014 9:04 PM, Scott Bryce wrote:
    > On 3/8/2014 5:23 PM, Alek Trishan wrote:
    >> I have a perl script that I can run by opening a command window and
    >> typing perl.exe myscript.pl
    >>
    >> I would like to create an "executable" file (but not a desktop
    >> shortcut) that, when clicked on, would execute that command.

    >
    > Windows still supports batch files, does it not?
    >


    Yes, it does.

    However, associating .pl with perl.exe means that I do not need a batch
    file as a workaround.
     
    Alek Trishan, Mar 10, 2014
    #5
  6. On 3/9/2014 12:28 PM, Alek Trishan wrote:
    > On 3/8/2014 10:26 PM, Jürgen Exner wrote:
    >> Alek Trishan <> wrote:
    >>> I have a perl script that I can run by opening a command window and
    >>> typing
    >>> perl.exe myscript.pl
    >>>
    >>> I would like to create an "executable" file (but not a desktop shortcut)
    >>> that, when clicked on, would execute that command.

    >>
    >> Very easy. You just need to associate the file type *.pl with your Perl
    >> interpreter. Normally the Setup process for your Perl system will do
    >> that automatically.
    >> But if the association is broken, then right-click on a *.pl file,
    >> select "Open With" and re-create the association to the Perl
    >> interpreter.


    And if your script doesn't require the cmd window, you can associate it
    with wperl.exe (same version of perl but doesn't show the cmd window).
    I believe ActivePerl associates .plw files with this by default.
    Handy for scripts that just run in the background or scripts that
    use Tk (or similar)


    >
    > Brilliant!!! Thanks so much. :)
     
    Brian Helterline, Mar 12, 2014
    #6
  7. Στις 10/3/2014 19:00, ο/η Alek Trishan έγÏαψε:
    > On 3/9/2014 9:04 PM, Scott Bryce wrote:
    >> On 3/8/2014 5:23 PM, Alek Trishan wrote:
    >>> I have a perl script that I can run by opening a command window and
    >>> typing perl.exe myscript.pl
    >>>
    >>> I would like to create an "executable" file (but not a desktop
    >>> shortcut) that, when clicked on, would execute that command.

    >>
    >> Windows still supports batch files, does it not?
    >>

    >
    > Yes, it does.
    >
    > However, associating .pl with perl.exe means that I do not need a batch
    > file as a workaround.




    In case you did not know, if you add the .PL to your %PATHEXT% system
    environment e.g.

    echo %PATHEXT%

    .COM;.EXE;.BAT;.CMD;.VBS;.PL


    you can run your "program.pl" by simple issuing program without the
    extension !
     
    George Mpouras, Mar 12, 2014
    #7
  8. Hi!

    There is simple tool included with both ActivePerl and Strawberry Perl,
    it's called pl2bat.

    Cheers,
    Tomasz

    Użytkownik Alek Trishan napisał:
    > I have a perl script that I can run by opening a command window and typing
    > perl.exe myscript.pl
    >
    > I would like to create an "executable" file (but not a desktop shortcut)
    > that, when clicked on, would execute that command.
    >
    > Can anyone help?
    >
    > Thanks.
     
    Tomasz Konojacki, Mar 19, 2014
    #8
    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. Replies:
    15
    Views:
    510
    Dave Thompson
    Aug 21, 2006
  2. pratap
    Replies:
    20
    Views:
    785
    Flash Gordon
    Mar 7, 2007
  3. Jason Cavett
    Replies:
    8
    Views:
    656
    Sanjay
    May 16, 2007
  4. Replies:
    0
    Views:
    460
  5. Thomas Luedeke
    Replies:
    5
    Views:
    200
    Victor H. Goff III
    Aug 24, 2008
Loading...

Share This Page