opening another program through windows service using python

前端 未结 1 1706
情话喂你
情话喂你 2020-12-11 12:50

I\'m trying to open/execute another program through windows service using python code. When the windows service gets started, another program i.e Notepad will be executed. T

相关标签:
1条回答
  • 2020-12-11 13:22

    Windows services run in session 0, and interactive programs run in a different session. Typically this will be session 1 when there is a single logged on user. Now, your code will be creating processes in session 0, since it runs in session 0. And so the interactive user desktop in session 1 cannot interact with those processes.

    It is possible to start processes the run in a different session from the process parent, but it is not at all easy: http://blogs.msdn.com/b/winsdk/archive/2009/07/14/launching-an-interactive-process-from-windows-service-in-windows-vista-and-later.aspx

    One possible way out for you is to run a background process that is started when each user logs on. The service can communicate with the background process using IPC and ask the background process to do the leg work of starting the process in the interactive desktop.

    0 讨论(0)
提交回复
热议问题