Skip to content

Executable Extension

Want to run a script in the command console that is not of type EXE, COM, BAT by just typing in the name of the script? Have a script in Perl or Python that you have that you want to run without typing the name of the interpreter with switches? It’s pretty easy to do in Windows.

  1. Open up System Properties and click on Environment Variables:

  2. Select the PATHEXT System variable and click on the Edit button.

  3. Add the extension you want. In this case, let’s add the extension for .PL so we can run Perl scripts without typing in the name of the Perl interpreter:

  4. Hit OK on the Windows.
  5. In an Explorer Window, Go to Tools -> Folders

  6. In the Folder Options Window, click on the File Types tab, and then click New:

  7. Type .PL for the File Extension

  8. Click OK then Click on the Advanced button to open up the Edit File Type and click on New…

  9. Enter the name of the interpreter:

  10. Hit OK for all Windows.
  11. You’re set and good to go.

Now let’s test it. Make a .pl file under c:\ called "add.pl". Make add.pl be:

$sum = $ARGV[0] + $ARGV[1];
print "\nSum of the numbers is: $sum\n\n";

 

Now let’s call it via the console by typing:

add 5 5

9

Dan View All

Blog owner.

%d bloggers like this: