Finding location of an executable in a windows machine?
MRAB
google at mrabarnett.plus.com
Fri May 15 13:32:21 EDT 2009
nonsense at mynonsense.net wrote:
> My python script calls another windows program file. I have the path
> to that program hardcoded in it. Is there a way for python to
> automatically find the path to this program?
>
> testapp_path = "C:\\Program Files\\testapp\\version\\61\\"
>
> Or do i have to do a brute force approach to searching all drives/
> folders till it finds a path matching my program name?
The path to the Python script is given by __file__. If your other
program is in the same folder then you can use:
other_app_path = os.path.join(os.path.dirname(__file__),
other_app_name)
More information about the Python-list
mailing list