473,386 Members | 1,820 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.

Remote Process.GetProcesses and SessionId

Hi,

I am trying to get the SessionId of processes on a remote machine using
System.Diagnostics.Process:

foreach (Process p in Process.GetProcesses("remotemachine"))
{
Console.WriteLine(p.SessionId.ToString());
}

SessionId is always 0 while Task Manager (on the remote machine) shows the
correct Session ID. Any ideas why?

Thanks,
Anders
Oct 26 '07 #1
2 9194
"Anders Bovin" <An*********@discussions.microsoft.comwrote in message
news:03**********************************@microsof t.com...
Hi,

I am trying to get the SessionId of processes on a remote machine using
System.Diagnostics.Process:

foreach (Process p in Process.GetProcesses("remotemachine"))
{
Console.WriteLine(p.SessionId.ToString());
}

SessionId is always 0 while Task Manager (on the remote machine) shows the
correct Session ID. Any ideas why?

Thanks,
Anders


Don't use this method, it's just a bag of bugs, use System.Management (WMI)
instead.

Following snip illustrates how you can get the Processes SessionId from a
remote server:
Check MSDN for more detail on WMI's Win32_Process class.
....
ConnectionOptions co = new ConnectionOptions();;
co.Username = "administrator"; //any account with appropriate privileges
co.Password = "pppppp";
string remMachine = "machineName";
ManagementScope scope = new ManagementScope(@"\\" + remMachine +
@"\root\cimv2", co);
SelectQuery selectQuery = new SelectQuery("Select Name, SessionId
from Win32_Process");
using(ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope, selectQuery))
{
foreach (ManagementObject proc in searcher.Get())
Console.WriteLine("{0}, {1}",proc["Name"].ToString(),
proc["SessionId"].ToString());
}
Willy.

Oct 26 '07 #2
OK! Will do.

Thanks Willy

"Willy Denoyette [MVP]" wrote:
"Anders Bovin" <An*********@discussions.microsoft.comwrote in message
news:03**********************************@microsof t.com...
Hi,

I am trying to get the SessionId of processes on a remote machine using
System.Diagnostics.Process:

foreach (Process p in Process.GetProcesses("remotemachine"))
{
Console.WriteLine(p.SessionId.ToString());
}

SessionId is always 0 while Task Manager (on the remote machine) shows the
correct Session ID. Any ideas why?

Thanks,
Anders

Don't use this method, it's just a bag of bugs, use System.Management (WMI)
instead.

Following snip illustrates how you can get the Processes SessionId from a
remote server:
Check MSDN for more detail on WMI's Win32_Process class.
....
ConnectionOptions co = new ConnectionOptions();;
co.Username = "administrator"; //any account with appropriate privileges
co.Password = "pppppp";
string remMachine = "machineName";
ManagementScope scope = new ManagementScope(@"\\" + remMachine +
@"\root\cimv2", co);
SelectQuery selectQuery = new SelectQuery("Select Name, SessionId
from Win32_Process");
using(ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope, selectQuery))
{
foreach (ManagementObject proc in searcher.Get())
Console.WriteLine("{0}, {1}",proc["Name"].ToString(),
proc["SessionId"].ToString());
}
Willy.

Oct 27 '07 #3

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

Similar topics

1
by: Mircea Pleteriu | last post by:
Hi all, I want to get the list of active/running processes on some remote machines in the same LAN my application run. I always get a System.InvalidOperationExpection exception with the message...
5
by: Jane | last post by:
Hi, I try Process remoteByName = Process.GetProcesses(); it works but when I try Process remoteByName = Process.GetProcesses("localhost"); it fails with invalid operation please Help me!...
7
by: Denis Brkljacic | last post by:
Hi, I have made some simple ASP.NET (C#) application, that somewhere uses this command: Process aProcesses = Process.GetProcesses(Environment.MachineName); This command purpose is to find...
1
by: Roger | last post by:
When looking through the list created by the System.Diagnositc.Process.GetProcesses and verifying it with the Task Manager Process list. There are items in the Task Manager Process list that are...
0
by: XxLicherxX | last post by:
Hello everyone, I a program that pulls the processes off of remote machines using the Process.GetProcesses() function. What I want to be able to do is get some information about the process,...
0
by: Nadav | last post by:
Does Process.GetProcesses("remoteMachine") requires .NET Frameworks on "remoteMachine" ? When I run it now, I get a message "Feature not supported on remote machine" although it works partially....
0
by: Mr. Novice | last post by:
Hello, I'm using the below code to display a list of processes running on a remote machine. The code successfully grabs five or six of the processes before getting an error that says "feature is...
0
by: 5000wpm | last post by:
"couldn't get process information from remote machine" - Access denied Using VS2003 VB.NET 1.1 under Windows XP Pro x64. Hi, Having recently upgraded to Windows XP Pro x64 a problem has...
7
by: xla76 | last post by:
Using WMI I can get the full path of a process on a remote computer: "SELECT ExecutablePath FROM Win32_Process" Without wmi I can get theprocessname and id: For Each ps In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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.