Process.GetProcessesByName throws exception

Discussion in 'ASP .Net Security' started by howard39@nospam.nospam, Oct 26, 2004.

  1. Guest

    We a Web application that has been running for months, but suddenly (i.e.
    over the weekend) stopped working.

    To narrow down the problem, I wrote the followng page_load handler in an
    ASP.Net test application:

    public void Page_Load(Object sender, EventArgs e)
    {
    Process currentProcess = Process.GetCurrentProcess();
    Process [] localByName = Process.GetProcessesByName("notepad");
    }

    GetCurrentProcess works, but GetProcessesByName throws the exception that I
    have appended to this message.

    The same code in a Console application works fine. The ASP.Net worker
    process is a member of the User group. However changing it to Administrator
    does not help. Nor does changing to Impersonation. Nor does including the
    name of my machine in GetProcessesByName.

    Would apreciate help on this.

    THE EXCEPTION MESSAGE (Note the "Couldn't get process information from
    remote machine" exception):

    Exception Details: System.ComponentModel.Win32Exception: Access is denied

    Source Error:

    Line 22: {
    Line 23: Process currentProcess = Process.GetCurrentProcess();
    Line 24: Process [] localByName = Process.GetProcessesByName("notepad");

    Line 25: }
    Line 26:


    Source File: c:\inetpub\wwwroot\testwebapplication\webform1.aspx.cs Line:
    24

    Stack Trace:


    [Win32Exception (0x80004005): Access is denied]
    System.Diagnostics.PerformanceMonitor.GetData(String item) +496
    System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item)
    +158
    System.Diagnostics.PerformanceCounterLib.get_CategoryTable() +80
    System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String[]
    categories, Int32[] categoryIndexes) +56
    System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
    library) +157

    [InvalidOperationException: Couldn't get process information from remote
    machine.]
    System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
    library) +259
    System.Diagnostics.NtProcessManager.GetProcessInfos(String machineName,
    Boolean isRemoteMachine) +152
    System.Diagnostics.ProcessManager.GetProcessInfos(String machineName) +37
    System.Diagnostics.Process.GetProcessesByName(String processName, String
    machineName) +69
    System.Diagnostics.Process.GetProcessesByName(String processName) +11
    TestWebApplication.WebForm1.Page_Load(Object sender, EventArgs e) in
    c:\inetpub\wwwroot\testwebapplication\webform1.aspx.cs:24
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +35
    System.Web.UI.Page.ProcessRequestMain() +731
    , Oct 26, 2004
    #1
    1. Advertising

  2. Guest

    The problem was that a new network security policy applied over the weekend
    removed the ASPNET account from the local Administrators group. On Windows
    2000 you have to be in the Administrators group in order for
    GetProcessesByName to work.

    When I added ASPNET back in to the Administrators group, I didn't reset IIS,
    and so I failed to see that GetProcessesByName was now working.
    , Oct 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Himmat Dhange
    Replies:
    0
    Views:
    417
    Himmat Dhange
    Aug 26, 2003
  2. Cowboy \(Gregory A. Beamer\)
    Replies:
    1
    Views:
    787
    =?Utf-8?B?amhpbGw=?=
    May 16, 2004
  3. Chris Miller
    Replies:
    4
    Views:
    13,270
    Chris Smith
    Nov 22, 2003
  4. Replies:
    2
    Views:
    324
  5. Dirc
    Replies:
    1
    Views:
    370
Loading...

Share This Page