locked
Access is denied error on GetCurrentProcess RRS feed

  • Question

  • User-1420724174 posted

    I don't know where to start so I will try here first. We are running some code on our web page as follows:

    System.Diagnostics.Process CurProc = System.Diagnostics.Process.GetCurrentProcess();

    When I access CurProc.MainModule.FileName I get the error

    "Access is denied"

    Here is the info for the process

    {System.Diagnostics.Process (w3wp)}
        base: {System.Diagnostics.Process (w3wp)}
        BasePriority: 8
        EnableRaisingEvents: false
        ExitCode: 'CurProc.ExitCode' threw an exception of type 'System.ComponentModel.Win32Exception'
        ExitTime: 'CurProc.ExitTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        Handle: 'CurProc.Handle' threw an exception of type 'System.ComponentModel.Win32Exception'
        HandleCount: 1795
        HasExited: 'CurProc.HasExited' threw an exception of type 'System.ComponentModel.Win32Exception'
        Id: 9336
        MachineName: "."
        MainModule: 'CurProc.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception'
        MainWindowHandle: 0
        MainWindowTitle: ""
        MaxWorkingSet: 'CurProc.MaxWorkingSet' threw an exception of type 'System.ComponentModel.Win32Exception'
        MinWorkingSet: 'CurProc.MinWorkingSet' threw an exception of type 'System.ComponentModel.Win32Exception'
        Modules: 'CurProc.Modules' threw an exception of type 'System.ComponentModel.Win32Exception'
        NonpagedSystemMemorySize: 232124
        NonpagedSystemMemorySize64: 232124
        PagedMemorySize: 298188800
        PagedMemorySize64: 298188800
        PagedSystemMemorySize: 1088496
        PagedSystemMemorySize64: 1088496
        PeakPagedMemorySize: 322125824
        PeakPagedMemorySize64: 322125824
        PeakVirtualMemorySize: 1124806656
        PeakVirtualMemorySize64: 1124806656
        PeakWorkingSet: 395051008
        PeakWorkingSet64: 395051008
        PriorityBoostEnabled: 'CurProc.PriorityBoostEnabled' threw an exception of type 'System.ComponentModel.Win32Exception'
        PriorityClass: 'CurProc.PriorityClass' threw an exception of type 'System.ComponentModel.Win32Exception'
        PrivateMemorySize: 298188800
        PrivateMemorySize64: 298188800
        PrivilegedProcessorTime: 'CurProc.PrivilegedProcessorTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        ProcessName: "w3wp"
        ProcessorAffinity: 'CurProc.ProcessorAffinity' threw an exception of type 'System.ComponentModel.Win32Exception'
        Responding: true
        SafeHandle: 'CurProc.SafeHandle' threw an exception of type 'System.ComponentModel.Win32Exception'
        SessionId: 0
        StandardError: 'CurProc.StandardError' threw an exception of type 'System.InvalidOperationException'
        StandardInput: 'CurProc.StandardInput' threw an exception of type 'System.InvalidOperationException'
        StandardOutput: 'CurProc.StandardOutput' threw an exception of type 'System.InvalidOperationException'
        StartInfo: {System.Diagnostics.ProcessStartInfo}
        StartTime: 'CurProc.StartTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        SynchronizingObject: null
        Threads: {System.Diagnostics.ProcessThreadCollection}
        TotalProcessorTime: 'CurProc.TotalProcessorTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        UserProcessorTime: 'CurProc.UserProcessorTime' threw an exception of type 'System.ComponentModel.Win32Exception'
        VirtualMemorySize: 1124511744
        VirtualMemorySize64: 1124511744
        WorkingSet: 372817920
        WorkingSet64: 372817920

    The process is the w3wp process.  I am running IIS 6, my .NET Runtime is set to 4.0, Enabled 32 bit is true, Managed Pipeline mode is integrated and the identity is "ApplicationPoolIdentity". 

    I am at a complete loss so any help would be appreciated, or please point me to the right forum.

    Thanks.

    Tuesday, January 19, 2016 3:02 PM

All replies

  • User398825048 posted

    You have to make sure that the account that execute your program have the rights to execute the program

    Try to change the user of the Application Pool to a local user on the server that has permissions to execute the process (preferable a non-admin account)

    Wednesday, January 20, 2016 8:03 AM