Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have developed an application that detects if it is already running using Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName) method.

But I have a customer with it installed on a Server 2003 that also hosts Remote Desktop connections. When these connections try to run the program they are told it is already running though naturally they have no access to it.

Is there a way of detecting if a program is running within a session rather than somewhere on the host computer?
Posted
Updated 7-Jun-12 9:44am
v3

1 solution

You can use a Windows function to determine if you are running on Remote Desktop (a session) or directly on the machine (host computer). Here is a Stack Overflow question with the information you need:

http://stackoverflow.com/questions/159910/determine-if-a-program-is-running-on-a-remote-desktop[^]
 
Share this answer
 
Comments
Maciej Los 7-Jun-12 15:45pm    
It might be it! +5
Graham Eady 8-Jun-12 9:47am    
Not quite the problem. I know its running in a remote session the problem is its picking up that another instance is already running elsewhere on the server. I only want to know if the program is running in this particular remote session so that every remote session has only one instance running in each. If there are 4 remote sessions running the program on the server then the server will have the program running 4 times but only once in each of the 4 remote sessions

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900