Python code does not work properly when I run the script as a windows service

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?

+3
source share
1 answer

, , . , - , ( , ).

+3

Source: https://habr.com/ru/post/1718204/


All Articles