Windows Vista - Process.GetProcessesByName doesn't work

Hi,
This code is written in c#.net windows application.
I am trying to get all the processes by name using Process.GetProcessesByName("Exe Name") and for some reason this doesn't work in Windows Vista, does anyone have any idea?

[264 byte] By [GaneshBala] at [2007-12-23]
# 1

What do you mean with that it doesn't work?

I did a quick test with C# express. I saw difference if the extension is included. Not sure if this is similar on XP, only have 1 computer.

Process[] arrP = Process.GetProcessesByName("explorer.exe"); // gives no items
arrP =
Process.GetProcessesByName("explorer"); // gives one item

AndreasJohansson at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 2

Here is the code that I tried,

Process[] allProcesses = Process.GetProcessesByName("Exe Name");

I throws an exception saying "Couldn't get process information from remote machine".

GaneshBala at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 3
I get the following exception for a similar code:

Process[]arrProcess=Process.GetProcesses(strMachineName);

System.InvalidOperationException:Cannot open Service Control Manager on computer xyz. This operation might require other previliges. > System.ComponentModel.Win32Exception: Access is denied.

It works fine when I am monitoring an application on my local computer by giving its IP Address. But it does not work for remote computers. I believe It has something to do with user accounts and privileges on both machines but not sure how to go about them. Please help me! I have enabled remote administration on the computer that is being monitored.

pkaur at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 4

I am having issues with Process.GetProcessesByName("Sierra") , the current software runs fine on XP but when I try to run it on Vista I get "Couldn't Get Process Information from Remote Machine" . The program is written in VB with VS2003. Any Ideas would be appreciated.

MHall at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 5
MHall wrote:

I am having issues with Process.GetProcessesByName("Sierra") , the current software runs fine on XP but when I try to run it on Vista I get "Couldn't Get Process Information from Remote Machine" . The program is written in VB with VS2003. Any Ideas would be appreciated.

As you get a remote machine error it seem you are trying to do it from a network drive. Copy the executable to machine you need to run it on and the security zone will be different and it might run.

AndreasJohansson at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 6
Thats the issue, I am running it from the local machine. It works under xp and it works under Vista if I turn off UAC, but not if UAC is enabled.
MHall at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 7

MHall wrote:
Thats the issue, I am running it from the local machine. It works under xp and it works under Vista if I turn off UAC, but not if UAC is enabled.

This seem to be by design. You can not get process information unless you have permissions to it. The Task manager seem to do it differently. Probably via WMI.

AndreasJohansson at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...
# 8

I found a solution.

On the Vista machine you have to start the "Remote Registry" service. Then you can get the processes from the Vista machine remotely. Otherwise it only works locally. Start the service and it works, stop the service and it doesn't. That simple.

I found the resolution at http://msdn2.microsoft.com/en-us/library/aa381831.aspx

which is instructions for getting the ITaskScheduler to work on Vista for scheduling tasks remotely. Fixing that corrected the Process.GetProcessesByName("exename", "vistapc") error I was getting.

Hope this helps,

Craig

cwilding at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...

Software Development for Windows Vista

Site Classified