Where? run directory

A

Adrian Smith

On a windows system.
I'm trying to get a Mcmillian created program to be 'independent' but
the first thing I need to do is find out where the program is being
run from, not the shortcut but the generated exe. This is where I keep
all the set-up files that I need to access.
Currently I have a fixed directory but don?t want to write anything
into the registry.
Is there a reg setting though that gives the address of the last run
program (presumably my program) or something like a working directory
setting.
I don?t want to have to search for the program through the directory
structure as that would be very time consuming.

Any Ideas out there would be very welcome
Thanks
 
E

Emile van Sebille

"Adrian Smith" asks,
On a windows system.
I'm trying to get a Mcmillian created program to be 'independent' but
the first thing I need to do is find out where the program is being
run from, not the shortcut but the generated exe. This is where I keep
all the set-up files that I need to access.
Currently I have a fixed directory but don?t want to write anything
into the registry.
Is there a reg setting though that gives the address of the last run
program (presumably my program) or something like a working directory
setting.
I don?t want to have to search for the program through the directory
structure as that would be very time consuming.

I think you're looking for:

import os
print os.path.dirname(__file__)


HTH,

Emile van Sebille
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,342
Members
48,018
Latest member
DelilahDen

Latest Threads

Top