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.
- Open up System Properties and click on Environment Variables:
- Select the PATHEXT System variable and click on the Edit button.
- 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:
- Hit OK on the Windows.
- In an Explorer Window, Go to Tools -> Folders
- In the Folder Options Window, click on the File Types tab, and then click New:
- Type .PL for the File Extension
- Click OK then Click on the Advanced button to open up the Edit File Type and click on New…
- Enter the name of the interpreter:
- Hit OK for all Windows.
- 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
Categories