I
I
Ilya Kozyrev2015-12-16 10:22:08
JavaScript
Ilya Kozyrev, 2015-12-16 10:22:08

How to send a WM_CLOSE message to an application in another session?

Everyone loves the day.
Introductory: there is a server, there are a lot of RDP sessions on it, a certain set of applications is launched in each session.
Question: How to "correctly" close applications in other people's sessions?
I tried it in c# through the Process class, using the CloseMainWindow method, but since this method causes the WM_CLOSE message to be sent, and it needs a window handle, the method does not work, since there is no window in the session from where the program is launched.
Can you please tell me any ideas how to implement this scheme? in c# or ++ or something else.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2015-12-16
@r3l0c

Run as administrator and get the handle / handles by the process name, get the information from which user the exe is running and if everything is OK, we end

I
Ilya Kozyrev, 2015-12-16
@WizaXxX

I run as administrator, but the MainWindowHandle property is also equal to 0. Accordingly, the CloseMainWindow() method does not work.

S
SerJook, 2015-12-20
@SerJook

1. You start your process in the desired session using CreateProcessAsUser
2. You send whatever you want from it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question