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.
- Open the Registry Editor by running regedit.
- Expand HKEY_CLASSES_ROOT > Directory.
- Right-click on shell under Directory and select New > Key.
- 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).
- 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.
- Enter the display name for your script in the Value data field. Click OK when you're done.
- Right-click on the name you entered in step 4 and select New > Key.
- Enter command.
- Click on the command folder. You'll see a (Default) value in the main window. Right-click on (Default) and select Modify.
- Enter the command line for your script in the Value data field. For example, perl.exe c:\work\perl\qaHelpTitles.pl. Click OK when you're done.
- Open an Explorer window and test by right-clicking on a folder and selecting the display name you entered.
- 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!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- 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
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||