0

I have an windows service made in Python. This is working fine. But I need get the file path where my service are installed. I have tried to use these codes bellow:

os.get getcwd()

Returns:

Windows System32 folder

os.path.realpath(__file__)

Returns:

NameError: global name 'file' is not defined

How can I get the file path to my windows service application?

4

1 Answer 1

1

Use sys.prefix to obtain the folder used for the EXE. This holds the EXE's folder when a utility such as py2exe has been used to create it.

sys.path for example will hold the path to python24.zip

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.