views:

92

answers:

1

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?

+2  A: 

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).

Vinay Sajip