ASP.NET, C#, Process.GetProcesses

D

Denis Brkljacic

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 some proccess on local machine and do
something. This works perfect on the machine (XP) where I have been
developing this app!

But then, when I copied my application on some other machine (Win2k), it
reports the error on this line, saying:

System.ComponentModel.Win32Exception: Access is denied

This is really strange, because it seems to grab the proccesses from the
remote machine (what is totally wrong, this should list the proccesses from
local machine). And the code is just copied from XP where this works fine.

Please if anybody can help me out with this...


Thanks,

/Denis
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Maybe it's the permission of the user under which the ASP.net process is
running.

Change it to an user with admin rights and see what happens

REMEMBER to change it back later !!!


cheers,
 
D

Denis

Thanks, but I have already tried this: Process [] aProcesses = Process.
GetProcesses();

The same thing, this works fine on the 'original' machine (XP), but when
copied to another one (win2k), I get access denied, trying to get processes
from 'remote machine'.

I have switched impersonation on and gave full rights to aspnet user, but
still no success... :(

Regards,

/Denis


Sun, 27 Feb 2005 01:05:29 +0200


----- Original Message -----
From: "Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> Sent: Sun, 27 Feb
2005 01:33:02 Subject: Re: ASP.NET, C#, Process.GetProcesses


Your parameter is incorrect. If you need processes running on the local
machine, you need to simply do a getprocess() and store the results in an
array. This is most likely the cause of the permissions error you are
experiencing since you do not have access to the remote process.

--
Regards
Alvin Bruney
[Shameless Author Plug] The Microsoft Office Web Components Black Book
with .NET available at www.lulu.com/owc
--------------------------------------------------


Ignacio Machin ( .NET/ C# MVP ) said:
Maybe it's the permission of the user under which the ASP.net process is
running.
Change it to an user with admin rights and see what happens
REMEMBER to change it back later !!!

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us Florida Department Of Transportation


Denis Brkljacic said:
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 some proccess on local machine and do
something. This works perfect on the machine (XP) where I have been
developing this app!
But then, when I copied my application on some other machine (Win2k),
it reports the error on this line, saying:
System.ComponentModel.Win32Exception: Access is denied
This is really strange, because it seems to grab the proccesses from
the remote machine (what is totally wrong, this should list the
proccesses from
local machine). And the code is just copied from XP where this works
fine.
Please if anybody can help me out with this...
Thanks,
/Denis
 
A

Alvin Bruney [Microsoft MVP]

Your parameter is incorrect. If you need processes running on the local
machine, you need to simply do a getprocess() and store the results in an
array. This is most likely the cause of the permissions error you are
experiencing since you do not have access to the remote process.

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
--------------------------------------------------


Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Maybe it's the permission of the user under which the ASP.net process is
running.

Change it to an user with admin rights and see what happens

REMEMBER to change it back later !!!


cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



Denis Brkljacic said:
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 some proccess on local machine and do
something. This works perfect on the machine (XP) where I have been
developing this app!

But then, when I copied my application on some other machine (Win2k), it
reports the error on this line, saying:

System.ComponentModel.Win32Exception: Access is denied

This is really strange, because it seems to grab the proccesses from the
remote machine (what is totally wrong, this should list the proccesses
from
local machine). And the code is just copied from XP where this works
fine.

Please if anybody can help me out with this...


Thanks,

/Denis
 
A

Alvin Bruney [Microsoft MVP]

This doesn't make sense. You obviously are doing something wrong because the
getprocess call should be running on the LOCAL machine not a remote machine.

Have a look at the help docs on the proper call. Finally, when you get the
call working, you will need to setup proper access rights. The webpage needs
to run under the correct account (u said you impersonate) but you still need
separate permissions for the process to request the info from the OS.

So you have 3 issues to deal with - one is getting the call configured
correctly, the other two has to deal with the aspnet worker process rights
and the machine rights to invoke the call.

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
--------------------------------------------------


Denis said:
Thanks, but I have already tried this: Process [] aProcesses = Process.
GetProcesses();

The same thing, this works fine on the 'original' machine (XP), but when
copied to another one (win2k), I get access denied, trying to get
processes
from 'remote machine'.

I have switched impersonation on and gave full rights to aspnet user, but
still no success... :(

Regards,

/Denis


Sun, 27 Feb 2005 01:05:29 +0200


----- Original Message -----
From: "Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> Sent: Sun, 27 Feb
2005 01:33:02 Subject: Re: ASP.NET, C#, Process.GetProcesses


Your parameter is incorrect. If you need processes running on the local
machine, you need to simply do a getprocess() and store the results in an
array. This is most likely the cause of the permissions error you are
experiencing since you do not have access to the remote process.

--
Regards
Alvin Bruney
[Shameless Author Plug] The Microsoft Office Web Components Black Book
with .NET available at www.lulu.com/owc
--------------------------------------------------


"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote
in message news:%[email protected]...
Maybe it's the permission of the user under which the ASP.net process is
running.
Change it to an user with admin rights and see what happens
REMEMBER to change it back later !!!

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us Florida Department Of Transportation


Denis Brkljacic said:
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 some proccess on local machine and do
something. This works perfect on the machine (XP) where I have been
developing this app!
But then, when I copied my application on some other machine (Win2k),
it reports the error on this line, saying:
System.ComponentModel.Win32Exception: Access is denied
This is really strange, because it seems to grab the proccesses from
the remote machine (what is totally wrong, this should list the
proccesses from
local machine). And the code is just copied from XP where this works
fine.
Please if anybody can help me out with this...
Thanks,
/Denis
 
D

Denis Brkljacic

Ok, thanks, I'll try that...


/Denis


Alvin Bruney said:
This doesn't make sense. You obviously are doing something wrong because
the getprocess call should be running on the LOCAL machine not a remote
machine.

Have a look at the help docs on the proper call. Finally, when you get the
call working, you will need to setup proper access rights. The webpage
needs to run under the correct account (u said you impersonate) but you
still need separate permissions for the process to request the info from
the OS.

So you have 3 issues to deal with - one is getting the call configured
correctly, the other two has to deal with the aspnet worker process rights
and the machine rights to invoke the call.

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
--------------------------------------------------


Denis said:
Thanks, but I have already tried this: Process [] aProcesses = Process.
GetProcesses();

The same thing, this works fine on the 'original' machine (XP), but when
copied to another one (win2k), I get access denied, trying to get
processes
from 'remote machine'.

I have switched impersonation on and gave full rights to aspnet user, but
still no success... :(

Regards,

/Denis


Sun, 27 Feb 2005 01:05:29 +0200


----- Original Message -----
From: "Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> Sent: Sun, 27 Feb
2005 01:33:02 Subject: Re: ASP.NET, C#, Process.GetProcesses


Your parameter is incorrect. If you need processes running on the local
machine, you need to simply do a getprocess() and store the results in an
array. This is most likely the cause of the permissions error you are
experiencing since you do not have access to the remote process.

--
Regards
Alvin Bruney
[Shameless Author Plug] The Microsoft Office Web Components Black Book
with .NET available at www.lulu.com/owc
--------------------------------------------------


"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote
in message news:%[email protected]...
Maybe it's the permission of the user under which the ASP.net process
is
running.
Change it to an user with admin rights and see what happens
REMEMBER to change it back later !!!


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us Florida Department Of Transportation


[email protected]...
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 some proccess on local machine and do
something. This works perfect on the machine (XP) where I have been
developing this app!
But then, when I copied my application on some other machine (Win2k),
it reports the error on this line, saying:
System.ComponentModel.Win32Exception: Access is denied
This is really strange, because it seems to grab the proccesses from
the remote machine (what is totally wrong, this should list the
proccesses from
local machine). And the code is just copied from XP where this works
fine.
Please if anybody can help me out with this...


/Denis
 
W

Willy Denoyette [MVP]

That means Environment.MachineName is returning a remote machine machine
name, which is impossible.
Your problem is a security privilege issue. The asp.net process identity is
missing the right security privileges to get the process list.
You should impersonate an administrator or run your asp.net process as an
administrator, or much better, run this piece of code in a server type COM+
(EnterpriseServices) application with identity set to an administrator's
account.

Willy.
 
A

Alvin Bruney [Microsoft MVP]

You can also try boosting the asp.net account to "System" for testing
purposes in the machine config. You would need to return it back to its
least priviledge account as it represents a significant security risk.

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
--------------------------------------------------


Willy Denoyette said:
That means Environment.MachineName is returning a remote machine machine
name, which is impossible.
Your problem is a security privilege issue. The asp.net process identity
is missing the right security privileges to get the process list.
You should impersonate an administrator or run your asp.net process as an
administrator, or much better, run this piece of code in a server type
COM+ (EnterpriseServices) application with identity set to an
administrator's account.

Willy.


Denis Brkljacic said:
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 some proccess on local machine and do
something. This works perfect on the machine (XP) where I have been
developing this app!

But then, when I copied my application on some other machine (Win2k), it
reports the error on this line, saying:

System.ComponentModel.Win32Exception: Access is denied

This is really strange, because it seems to grab the proccesses from the
remote machine (what is totally wrong, this should list the proccesses
from
local machine). And the code is just copied from XP where this works
fine.

Please if anybody can help me out with this...


Thanks,

/Denis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top