Dynamic language interpreters (“script engines”) in Windows don’t normally install in such a way that once you write a script, you can simply call it on the command line.
If you have a script named hello.py, you cannot just type “hello” at the command line and hope it will work. It won’t.
The file extension has to be registered as an executable file, and the default program for opening the script must be its appropriate interpreter.
- Create a directory at C:mybin
- right-click on the My Computer icon on your desktop or in the Windows Start menu (in Win7 it is just called “Computer” and select ‘Properties’)
- Click on the Advanced Settings button, and then on the Environment Variables button
- Edit the PATH variable in System Variables, add the following to the end of its data:
(note: the semi-colon ‘;’ is important)
- save and return to the desktop.
We now assume that the scripts you want to run get saved to C:mybin
You will need to use the `assoc` and `ftype` commands to achieve this
1) Associate a file extension to a pattern name
2) Define the handling in the pattern:
ftype jarfile="C:jsdk-1.6.0_18binjava.exe" -jar "%1" %*
Surround the path to the executable with quote marks as best practice.
Surround the %1 argument with double quotes as well – this is the path to your runnable file; if it has spaces in its path, you need the double quotes to keep it whole.
Do not surround %* with quotes, this represents all the arguments that were initially specified on the command line.