scriptrun 1.0


One big annoyance about programming under Windows is cmd.exe's inability to directly execute scripts. Under UNIX, all you need to do to make a Python or shell script executable is set the "execute" flag and change the first line so it contains "#!" followed by the script engine. Under Windows, you can double-click to launch scripts, but running them from the shell is more problematic.

scriptrun is the answer! Just copy it into the same directory as the script and rename it to <<scriptname>>.exe. Now you can just run <<scriptname>> from the command-line. scriptrun takes care of the rest.

Highlights of scriptrun:

The scriptrun web page is here:
And you can download a fresh copy of it here, including full source:


Here's the thirty-second description of how to use scriptrun. Let's say you have a script called Follow these steps:

  1. Copy scriptrun.exe into the same directory as
  2. Rename scriptrun.exe to useful.exe.
Now you can run useful from the command-line. This, in turn, will run python.exe (scriptrun figures out the name of the script you wanted run based on its own name!)


scriptrun only itself recognizes one argument:

Set arguments to pass in to the script program. For instance, if you rename scriptrun.exe to foo.exe so it will run, you could run foo -sr:-v, and the -v would get passed in as so:
python.exe -v
All other arguments are passed on to the child process's command-line.

How scriptrun Finds Its Script

scriptrun follows these steps to find the script:

  1. First, if you rename scriptrun to the exact name of a recognized script in its directory (appended with .exe), it will always use that script. For instance, if you rename scriptrun to and there's a in the current directory, it will always execute
  2. Second, it will remove the .exe from its filename and try each extension for a supported file to see if it exists in the current directory. As of the 1.0, it would try these extensions in this order:
  3. Third, if all else fails, it will strip the .exe from its name and add .* to look for all files in the current directory for that name. If it finds exactly one (not counting the scriptrun executable itself) it assumes that's the script you meant.

How scriptrun executes the script

scriptrun follows these steps to decide on the command-line it will run:

  1. If it's a file type that supports the UNIX "#!" convention, it will open the file and read in the first 4k (or as much as there is). If the first two bytes are "#!", it assumes the rest of the line is the command-line it should use.
  2. Failing that, if an environment variable exists named SCRIPTRUN_<<extension>> (where <<extension>> does not include the leading period) it uses that. So, for instance, you can set SCRIPTRUN_PY to change how scriptrun executes Python scripts.
  3. Finally, scriptrun has a default list of programs to match all the out-of-the-box scripting languages.


Here's the license:

** Copyright (C) 2005 Larry Hastings
** This software is provided 'as-is', without any express or implied warranty.
** In no event will the authors be held liable for any damages arising from
** the use of this software.
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute
** it freely, subject to the following restrictions:
** 1. The origin of this software must not be misrepresented; you must not
**    claim that you wrote the original software. If you use this software
**    in a product, an acknowledgment in the product documentation would be
**    appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
**    misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
** The scriptrun homepage is here:
In non-legalese, my goal was to allow you to do anything you like with the software, except claim that you wrote the original version. If my license prevents you from doing something you'd like to do, contact me (my email address is in the source) and we can discuss it.

Version History

Monday, February 14th, 2005
Initial public release.

Happy executing!