Click here to Skip to main content
14,333,460 members
Rate this:
Please Sign up or sign in to vote.
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?
Updated 7-Jun-12 9:44am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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:[^]
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100