473,761 Members | 9,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get owner of a process

Hi

I am writing a program for a terminalserver.
But the program should startet only once
so i write a methode which returns if the process is running:
....
Process[] processes = Process.GetProc essesByName(Pro cessName);

if(processes.Le ngth > 1)
{
return true;

}
else
{
return false;
}
....

so now me problem.

I want that every user on the terminalservice can start the program once!

But when sameone starts it a other user can't start it too!

so i must check the user of the process.
who can i get the owner of the process?

thx

greets tim
Nov 16 '05 #1
1 4200
Hi Tim:

What you want to create is a 'named mutex' with the
System.Threadin g.Mutex class. I believe the documentation even has a
sample demonstrating how to ensure only one instance of an application
is running.

A Mutex is a kernel object and goes into a 'namespace' for the
terminal service session (not to be confused with .Net namespaces -
it's a kernel object namespace which prevents naming conflicts just
like a .NET namespace). This means it prevents multiple instances of
the application from running in the *same* terminal services session.

Just in case you wanted only one instance of the application for the
entire machine, you can put the Mutex in the global namespace by
prefixing the name with 'Global\'.

You'll find this approach to be more robust then searching through the
process list.

HTH,

--
Scott
http://www.OdeToCode.com

On 18 Aug 2004 00:57:33 -0700, tb*@uni.de (Tim B) wrote:
Hi

I am writing a program for a terminalserver.
But the program should startet only once
so i write a methode which returns if the process is running:
...
Process[] processes = Process.GetProc essesByName(Pro cessName);

if(processes.L ength > 1)
{
return true;

}
else
{
return false;
}
...

so now me problem.

I want that every user on the terminalservice can start the program once!

But when sameone starts it a other user can't start it too!

so i must check the user of the process.
who can i get the owner of the process?

thx

greets tim


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3517
by: ravi | last post by:
Hello everyone, Could any one tell me how to find the username(owner name) from a process handle or a process ID. ? thank you for your help Ravi
0
1395
by: Durval Mateus | last post by:
Hello, I need to know the owner of a process, but the process class does not have that info. How can i retrieve the owner info? thanks in advance, Durval Mateus
1
4317
by: DD | last post by:
I'm not sure that this msg made it out, the first time I sent it, so I am trying again. -- Win XP Home Edition I use System.Diagnostics.Process.GetProcesses()) to get info about the processes running. I don't see any members of class' Process' which allows me to get the name of the owner of the process.
2
5046
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
7
3655
by: Dave Coate | last post by:
Hi everyone, I am looking for a way to 'override' file security and read the Owner of a file to which I have no access. I am a system administrator, as such I have administrative rights to all the computers in the company. Some of my user base has full control rights to their files and have elected to remove my access to some files. It is possible for an administrator to regain access, but it is a messy process and can be time consuming....
3
4016
by: Dave Coate | last post by:
Hello again, I am going to re-post a question. I got some excellent suggestions from Rob and Mattias on this but their ideas did not solve the problem. Here is the original post: ***************************************************** I am looking for a way to 'override' file security and read the Owner of a file to which I have no access. I am a system administrator, as such I have administrative rights to all the computers in the...
2
3438
by: levimc | last post by:
I know that that topic may be old to you but I looked at other more- than-two-year-old topics related to mine. However, I didn't find them working for my project at all because its errors return back to me everytime. The error I have on that project said: "An unhandled exception of type 'System.EntryPointNotFoundException' occurred in TestSysaudit.exe
1
1785
by: Vishal Sethia | last post by:
Just trying to understand the behaviour of spawn. Consider I have a function which creates two threads. And in one of the threads I make a call to pexpect.spawn. spawn would fork and create a new new child In this case who becomes the owner of this child process. Is it the thread that spawned becomes the owner or is the main program becomes the owner of that child process. Thanks, -V
2
2187
by: stefan.albert | last post by:
Hello Ravi, what you want to do is very tricky, but possible. I've had this same problem - we want to identify the top user of tempspace and eventually force him off when using too much space (FS runs full). For temptables (NON-DGTT) you can use db2pd to find the owner (- tcbstats) here the application handle (agent id) is listed. But this won't help for DGTTs, because this information isn't given. --Serge : This would be a nice...
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.