A user logged into machine and run my application. without closing the application he just did switch user. The second user logged in and again run my application.
In this case, I want to kill the first instance from the second instance without any intimation to the first user.
When running my application I am writing the PID of the instance in a text file (in common path for the users). Then, I've have placed a timer to keep track of changes in PID from text file. If it differs from the instance's PID and then the instance will kill by itself.
To improve the performance of code, I wanna remove the timer logic.
Note: Both the users are normal users, don't have admin rights
I tried the followings, nothing worked out.
Approach 1: Kill by Process ID
Tried to kill the first instance by using PID from the second user's instance. Able to get the first process(ProcEntry) and terminateprocess is not killing the first instance, even it doesn't throw any error.
Tried to set the privilege(SE_DEBUG_NAME) and it is failed due to the user is not an admin.
Approach 2: Kill by Mutex I didn't get enough information on this to kill the process.
Approach 3:Kill by Passing WIN API message
It is not possible to pass messages between applications of different users by using PostMessage method.
Approach 4: Using named pipes
I'm not familiar with this approach.