Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:56:46+00:00 2026-06-14T09:56:46+00:00

I have an application in .Net that does various admin/config for other applications. I

  • 0

I have an application in .Net that does various admin/config for other applications. I need to be able to stop and start the app pool. I’ve achieved this, but only if I run the app pool as local system (which is generally accepted as a bad idea).

Initially I started appcmd.exe with Process.Start (using appropriate ProcessStartInfo object), but this eventually lead me to an Exit Code of -1073741502, further research suggests that I need to debug using the windows SDK as it has something to do with an assembly not loading, so I found what seems like a simpler solution in the Microsoft.Web.Administration namespace:

I use the below code, but it seems to require the AppPool running it has an identity of local system (otherwise I get System.UnauthorizedAccessException) – is there a way to start/stop with a less privileged account (I would prefer using Application Identity) – although temporarily elevating permissions is also acceptable.

    Dim serverManager As New ServerManager()
    Dim applicationPoolCollection As ApplicationPoolCollection = serverManager.ApplicationPools

    For Each applicationPool As ApplicationPool In applicationPoolCollection

        If applicationPool.Name = appPoolName Then
            applicationPool.Stop()
            applicationPool.Start()
        End If

    Next

I’ve set a custom account as the Identity, but I can’t work out what the minimum ACL for that user needs to be. As a test, I added the user to the local administrators group, but still get System.UnauthorizedAccessException – this suggests I need to configure a particular permission for the user, but I’m unsure what this is or how to do it. Can anyone help?

Problem is explained here also

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:56:47+00:00Added an answer on June 14, 2026 at 9:56 am

    Using @CarlosAg answer, the following solution works:

    1. Create a new User and put them in the Administrators Group

    2. Create a web service to run the restart code, put it in it’s own application pool running as a user you created (configure appropriate app pool properties, e.g. queue length etc)

      a. Put below code in your web method (or begin_reqest) to prevent it from being called externally (I think there are other ways to do this in IIS as well, but this was the quickest method I found)

      b. Add additional authentication to web service code as you see fit (we have a Single sign on service I can use).

    3. Reference this service from the web site which is running in an app pool under ApplicationIdentity

    This works.

    Code:

         If Not HttpContext.Current.Request.IsLocal Then
             Const msg As String = "Only local requests are allowed"
             log4net.LogManager.GetLogger(GetType(Global_asax)).Fatal(msg)
             Throw New Exception(msg)
         End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net Application that sends text messages to mobile phones. It does
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I have application in VB.net that have two different form (Form1 and Form2). Now
I have .NET application that is hosted on IIS 6.1 It is impossible to
I have a datalogging application (c#/.net) that logs data to a SQLite database. This
I have an application in vb.net that starts with a sub function do some
I have an application (ASP.NET MVC) that uses a Next New method to get
I have a .NET application that I want to use as a client to
We have a .net application that we didn't develop, but use. I can tell
I have a .Net application that dynamically creates a small HTML page and pops

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.