script filename and autorun

Peter Hansen peter at engcorp.com
Tue Mar 18 09:42:53 EST 2003


Simon Dahlbacka wrote:
> 
> I was thinking that I wanted to "autostart" my python program at bootup, I'm
> using windows and planned to use the registry through the win32api
> functions.
> 
> 1) how do I get the filename of the current script running? (I want to
> detect location at runtime)

import sys
currentScript = sys.argv[0]

> 2) is it enough with just a key "python
> c:\whateverthepathistomyprogram\prog.py" in ...\Run or do I also need full
> path to python?

Why not try it?  Normally a file association is set up so that "executing"
a .py file will automatically invoke Python, but it's conceivable this
doesn't work for items in "Run".  It's really rather easy to try this
though.

The real question, though, is why don't you just drag a shortcut to your
.py file to the Startup folder?  That way you are guaranteed that the
usual file associations will work, and it's much easier than munging
around in the registry.

-Peter




More information about the Python-list mailing list