473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Searching the process list

I want to iterate the process list looking at the processes running for the
current user. So I'm using:

foreach (Process p in Process.GetProcesses())
{

}

But I can't see any method or property of the Process object p which tells
me the username of the user running the process. p.StartInfo.UserName always
seems to contain "".

So how can I consider just the processes running under the current user ?

Mar 29 '06 #1
1 1783

"JezB" <je***********@blueyonder.co.uk> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
|I want to iterate the process list looking at the processes running for the
| current user. So I'm using:
|
| foreach (Process p in Process.GetProcesses())
| {
|
| }
|
| But I can't see any method or property of the Process object p which tells
| me the username of the user running the process. p.StartInfo.UserName
always
| seems to contain "".
|
| So how can I consider just the processes running under the current user ?
|
You can't use the Process class for this, you will have to use
System.Management and the WMI classes Win32_logonsession and Win32_Process,
or you have to call the Terminal server API's (WTSEnumerateProcesses,
WTSProcessInfo, WTSOpenServer, WTSCloseServer ....) and pass thSID obtained
by WTSProcessInfo to LookupAccountSid using PInvoke.

Willy.
Mar 29 '06 #2

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

Similar topics

4
by: tgiles | last post by:
Hi, all. Another bewildered newbie struggling with Python goodness. This time it's searching strings. The goal is to search a string for a value. The string is a variable I assigned the name...
3
by: aaj | last post by:
This is a simple question compared to some of the stuff that gets asked (and answered) here, but sometimes its easy to over look the simpler things. I've been working with databases for a few...
4
by: James | last post by:
We have a need to search through an entire drive for a specific file name. The process is currently written with recursive loops through each directory and the Scripting.FileSystemObject. Problem...
6
by: calan | last post by:
Relative SQL newbie here......this is probably easy, but.... Lets say I have a table (MainTable) that stores a list of input table names, a primary key (PKey), and a field called "Configured" for...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
29
by: jaysherby | last post by:
I'm new at Python and I need a little advice. Part of the script I'm trying to write needs to be aware of all the files of a certain extension in the script's path and all sub-directories. Can...
12
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
1
by: alamodgal | last post by:
hiiiiiii I have a problem in highlighting searching keyword.Actually im using this function for searching Public Function HighLight(ByVal Keyword As String, ByVal ContentFor As String) Dim...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.