title: How to open subprocess in services session?
body: <p>I have a Windows scheduled task written in Python. It opens standalone processes in the background as follows:</p>
  
  <pre><code>startupinfo = subprocess.STARTUPINFO()
  startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
  subprocess.Popen(appName,
      startupinfo = startupinfo,
      creationflags = subprocess.CREATE_NEW_CONSOLE,
      close_fds = True)
  </code></pre>
  
  <p>It looks like the child processes inherit the parent's session id.
  If the user is logged on in an interactive session, the task and its child processes run under the user's session. If the user is not logged in, the task and its child processes run in the services session (in task manager - Session ID 0).</p>
  
  <p><strong>Is there any way to open processes in the services session always, independent of the parent's session?</strong></p>
  
  <p>The problem is that when the logged on user's session ends, all child processes are terminated.</p>