1

I am working on Windows-service written in Python. I'd like to notify user about something, since it seems it cannot be done in service itself I've compiled small program tip.exe, that pops task-bar notifications. Usage is: path/to/tip.exe "title" "notification text" If I use it manully in cmd it works, but all my attempts:

 command='"{}" "{}" "{}"'.format(balloon_exe, title, message)
result=subprocess.Popen(command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
        output, errors = result.communicate()
#######
os.system(command)
#######
os.popen(command)

And some others. There is no error output nor exception... Anyone could help me, please?

  • There's no need for `shell=True`. But you can't use `subprocess.Popen` for this anyway since it calls `CreateProcess`, which can only create a process in the current session. For a service in Vista+, that's session 0, the non-interactive services session. – Eryk Sun May 06 '16 at 03:24
  • You can get the token for the active console session via [`WTSGetActiveConsoleSessionId`](https://msdn.microsoft.com/en-us/library/aa383835) and [`WTSQueryUserToken`](https://msdn.microsoft.com/en-us/library/aa383840). Then call [`CreateProcessAsUser`](https://msdn.microsoft.com/en-us/library/ms682429) or [`CreateProcessWithTokenW`](https://msdn.microsoft.com/en-us/library/ms682434). – Eryk Sun May 06 '16 at 03:24
  • Please see [this one](http://stackoverflow.com/questions/4207761/c-gui-to-display-realtime-messages-from-windows-service/4211466#4211466) – Eugene May 06 '16 at 06:40

0 Answers0