Click here to Skip to main content
13,091,894 members (58,437 online)
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?
Posted 7-Jun-12 6:05am
Updated 7-Jun-12 9:44am
Maciej Los255.5K

1 solution

Rate this: bad
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:[^]
losmac 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 7 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100