Python Forum
win32 API: Launch Application to RDP session from background process python script - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: win32 API: Launch Application to RDP session from background process python script (/thread-27182.html)



win32 API: Launch Application to RDP session from background process python script - rangeshgupta - May-28-2020

Hello,

I am trying to launch the application in RDP session from the background process which is python script. Here background script and RDP session is same user.

I tried win32process.CreateProcess but it runs application in background.

si = win32process.STARTUPINFO()
si.dwFlags = win32process.STARTF_USESHOWWINDOW
si.wShowWindow = win32con.SW_SHOW
si.lpDesktop = 'winsta0\default' 

procHandles =  win32process.CreateProcess(None,'notepad',None, None, 0,win32process.CREATE_NEW_CONSOLE, None, None, si)
Other option I tried is win32process.CreateProcessAsUser. But for it I need RDP user token by calling function win32ts.WTSQueryUserToken and it required special privilege to get the access token for user RDP session. Which user account doesn't have.

Is there any way I can achieve it.


Thanks
Rangesh