Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any shell extension for Explorer that would execute text files with a #! shebang at the beginning?

share|improve this question
You might try to add the file type extension to the registry so that it executes the given program on run or do something like this. – new123456 Jun 23 '11 at 5:11
I don't think so. The registry only holds suffixes. I Googled around, but could not find anything. – KCotreau Jun 23 '11 at 5:26
Hmm... does this work? – new123456 Jun 23 '11 at 5:38
You need to be more specific... What kind of executable are you tying to create? Did you change permissions to make your "Text File" executable? What shell are you trying to use (e.g. #!/bin/bash) ? – chrsblck Jun 23 '11 at 8:28
@chrsblck But I don’t remember Windows supporting marking things “executable”… – binki Dec 26 '15 at 17:09

You're very much in conflict with the Microsoft model for files. In the POSIX model, the filename doesn't dictate whether a file is executable, at all. That's solely the province of the permissions. In the Microsoft model used in Windows Explorer, whether a file is executable is also determined by its filename, in particular by the extension. Hence the FTYPE command, the ASSOC command, the PATHEXT environment variable, and so forth.

So, with the proviso that this is restricted to files with the .CMD extension, in order to fit in with the aforementioned model, there actually is an extension that will pass files beginning with #! to the script interpreter named on that line. It's JP Software's TCC, a replacement command interpreter which has both #! and EXTPROC support. Explorer can be told to hand off all .CMD files to TCC, which in turn will read the #! and hand off to the named script interpreter.

If you want to use #! with any other file extensions in Explorer, then you hit the paradigm conflict, and you'll have to switch to using file extension associations, just like the person with the CGI script did in the article hyperlinked-to by new123456. Extension determining script interpreter, not magic numbers in file contents, is the paradigm that Windows Explorer uses.

share|improve this answer

If your text file happens to by a Python File then you can do exactly what you want using pylauncher.
From the docs:

PEP 397 compatible launcher for Python under Windows. See for PEP, for screencast

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.