473,473 Members | 4,208 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 9206
"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
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
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...
1
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...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...
0
muto222
php
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.