473,396 Members | 1,789 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,396 software developers and data experts.

ASP.NET, C#, Process.GetProcesses

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
Nov 16 '05 #1
7 6832
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" <de***********@nospam.hr> wrote in message
news:cv**********@fegnews.vip.hr...
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

Nov 16 '05 #2
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:%2****************@TK2MSFTNGP12.phx.gbl...
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" <de***********@nospam.hr> wrote in message
news:cv**********@fegnews.vip.hr...
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


Nov 16 '05 #3
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:%2****************@TK2MSFTNGP12.phx.gbl...
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" <de***********@nospam.hr> wrote in message news:
cv**********@fegnews.vip.hr...
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

Nov 16 '05 #4
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" <de**********@vip.hr> wrote in message
news:11********@denisdbAbC01.vip.hr...
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:%2****************@TK2MSFTNGP12.phx.gbl...
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" <de***********@nospam.hr> wrote in message news:
cv**********@fegnews.vip.hr...
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

Nov 16 '05 #5
Ok, thanks, I'll try that...
/Denis
"Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <de**********@vip.hr> wrote in message
news:11********@denisdbAbC01.vip.hr...
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:%2****************@TK2MSFTNGP12.phx.gbl...
> 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" <de***********@nospam.hr> wrote in message news:
> cv**********@fegnews.vip.hr...
>> 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


Nov 16 '05 #6
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" <de***********@nospam.hr> wrote in message
news:cv**********@fegnews.vip.hr...
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

Nov 16 '05 #7
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 [MVP]" <wi*************@pandora.be> wrote in message
news:ev**************@TK2MSFTNGP12.phx.gbl...
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" <de***********@nospam.hr> wrote in message
news:cv**********@fegnews.vip.hr...
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


Nov 16 '05 #8

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

Similar topics

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!...
2
by: alvis | last post by:
hi i have a windows service that uses an excell workbook when i create the excell app i cant distroy it after i am finished i am using this code whats wrong? thanks Dim processes1(), p1 As...
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...
7
by: Gamma | last post by:
I'm trying to create a ListBox that holds list of currently running processes. So I inherited from Process a classes named _Process, which it's objects are to be held in the ListBox (I just...
1
by: Chris | last post by:
Hello, I have a Windows Forms application which has buttons to click to run other programs. One of the applications it must run is a ClickOnce Windows Forms application, so the Application...
4
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I know I can use this code to start a process. Any aimilar way to end one? System.Diagnostics.Process.Start("EcpKpScript_01.exe");
3
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I am using the following code to see if a process is currently running. I want to do something if it is NOT running. I am having trouble testing the array when no process is runing. Null won't...
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...
5
by: ags5406 | last post by:
I've a Windows Service that keeps a particular executable running. If the executable fails for whatever reason, the Service restarts it. Right now I'm using a loop to check if the process is...
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
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:
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...
0
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...

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.