Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Perl template file in windows new menu

by inman (Curate)
on Mar 22, 2004 at 10:27 UTC ( #338593=perlquestion: print w/replies, xml ) Need Help??
inman has asked for the wisdom of the Perl Monks concerning the following question:

On my old PC, I had set up a template associated with Perl so that you could right click the mouse in a directory and choose 'New Perl Script'. The file itself would be copied from a template file. This shortcut was very handy for starting new scripts quickly.

The association consists of a registry setting (to connect the .pl extension with the ability to make a new file) and the template file itself (held under the system directory).

Despite much Googling, I have been unable to reproduce the configuration under Windows XP professional. My old setup was W2K. I would be grateful for advice in this matter.

Replies are listed 'Best First'.
Re: Perl template file in windows new menu
by Roger (Parson) on Mar 22, 2004 at 11:53 UTC
  • Save the Perl template you wish to use immediately under C:\windows\ShellNew -- it is a hidden folder.
  • Start the Registry Editor
  • Open HKEY_CLASSES_ROOT and find the extension for that file type. Add a new key called ShellNew
  • Under the new key, add a string value called FileName
  • Double-click on the string, and modify it to be the filename of the blank template file you created, including the extension
  • Exit the Registration Editor and restart Windows

      This is what I tried without success (hence my frustration). I have just installed TweakUI which has a facility to manage templates. I noticed that the template files have been moved under Windows XP. They are now in the C:\Documents and Settings\All Users\Templates directory.


      update: The Tweak UI procedure

      1. Load up TweakUI and find the 'Template' section in the left hand tree.
      2. Press the 'Create' button and browse to a Perl script that you want to use as a template. (at this point however the contents of the file don't really matter).
      3. TweakUI copies this file to C:\Documents and Settings\All Users\Templates and for some reason gives it a numeric filename. You can edit this file to contain the defaults that you are looking for in a template.
      4. Restart your PC (This is required since Windows Explorer needs to scan your registry for ShellNew keys)

      You can also add a suitable description such as 'Perl Script' to the default value of the HKCR/Perl registry key so that Explorer prompts you with 'new Perl Script' rather than 'new .pl file'

Re: Perl template file in windows new menu
by ambrus (Abbot) on Mar 22, 2004 at 19:21 UTC

    I don't know how to put the entry in the "new" menu, however I'll give you a suggestion on how to acheive similar effect.

    When you select a directory, you get the familiar items open, expolre, find in the File menu and in the sf10 menu. You can add a new item under these, in the file associations dialog, that has an action like c:\windows\command\ /c echo, ">%1\", replacing command\ with system32\cmd.exe on NT-derived systems (including XP). Then, if you open a folder in Explorer, you can show the folder tree on the left side, select the folder in the tree, right-click on it, and chose the action. Then, the file "" gets created.

    I used a similar technique on my windows: I created an action c:\windows\command\ /k cd "%1", which spawns a new shell window that cd's in the directory.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://338593]
Approved by Corion
Front-paged by rupesh
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-02-22 10:00 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (289 votes). Check out past polls.