Here is the code for getting the desktop in Windows Vista.
import pythoncom
import win32com.client
pythoncom.CoInitialize()
shell = win32com.client.Dispatch("WScript.Shell")
desktop_path = shell.SpecialFolders("Desktop")
The code works fine when I tried to use the python interpreter, but it does not work when I execute the same code from a Python script that works as a Windows service. The function returns the desktop as an empty string.
Any idea what's wrong here? Is there any other alternative for getting a working path when a python script works as a windows service?
source
share