3

Here is the code to get Desktop path on Windows Vista.

import pythoncom
import win32com.client

pythoncom.CoInitialize()
shell = win32com.client.Dispatch("WScript.Shell")
desktop_path = shell.SpecialFolders("Desktop")

Code works fine when I tried on python interpreter but its not working when I execute the same code from Python script, which runs as a windows service. Function returns desktop path as empty string.

Any idea what is wrong here? Is there any other alternative to get Desktop path when python script runs as Windows Service?

1 Answer 1

3

Most likely, your service is running under an account which doesn't have a user desktop folder. Also note that by default, services have no access to the GUI - if your app has one, you have to mark your service as being allowed to interact with the desktop (user session, not folder).

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.