Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Note: This isn't really a Perl thing, but I'm using it for Perl scripts and it's too handy not to share.

I have a few scripts that I run frequently for work. Most parse the files in a directory and create an HTML report file. I wanted to share these with coworkers, but didn't want to have to explain the command prompt to them. My solution was going to be telling everyone to stick the .pl file in their local directory and then double-click it. (They already have Perl installed.) The problem is that we need to run these scripts in many, many directories and there are too many potential problems that can occur when you have multiple copies of the same script all over a hard drive.

I was thinking about a way to make this easier. The best idea I had was to allow them to right-click on a folder in Explorer and run the script from the context menu. I just had no idea how to do that. Thanks to Windows 98 Right Mouse Click Customisation, I was able to figure it out.

If you're interested in trying this, here are the steps.

Note: These instructions were written and tested using Windows 2000. They may be different for your version. Oh, and it's the registry, be careful in there. If you don't know the risks of editing registry keys, then don't do it.

  1. Open the Registry Editor by running regedit.
  2. Expand HKEY_CLASSES_ROOT > Directory.
  3. Right-click on shell under Directory and select New > Key.
  4. Enter a name for the script you're adding. I don't know if there are restrictions, but since this is not for display, don't use anything by letters and numbers (just to be safe).
  5. Left-click on the name you just entered. You'll see a (Default) value in the main window. Right-click on (Default) and select Modify.
  6. Enter the display name for your script in the Value data field. Click OK when you're done.
  7. Right-click on the name you entered in step 4 and select New > Key.
  8. Enter command.
  9. Click on the command folder. You'll see a (Default) value in the main window. Right-click on (Default) and select Modify.
  10. Enter the command line for your script in the Value data field. For example, perl.exe c:\work\perl\ Click OK when you're done.
  11. Open an Explorer window and test by right-clicking on a folder and selecting the display name you entered.
  12. If everything worked, then close the Registry Editor. If there were problems, then you may want to verify that perl.exe is in your path or the path and filename for the script are correct. Try pasting the command line into a Command Prompt window and running it that way. If it works, then I'm not sure what went wrong here. Sorry.

Hope this helps!

In reply to (Not Quite Perl) Running Scripts from Right-Click Context Menu in Windows by svsingh

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (8)
    As of 2018-06-25 18:08 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (128 votes). Check out past polls.