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 6964235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:53:56+00:00 2026-05-27T15:53:56+00:00

I am trying to create a simple web form which will give me a

  • 0

I am trying to create a simple web form which will give me a service restart button onscreen.

Upon clicking the button, I am creating an SMO object to talk to a SQL Server database and trying to stop and start the MSSQLSERVER service. All goes well until the Stop() method is called, at which point an exception is thrown stating:

Access is denied. (Exception from HRESULT: 0x80070005
(E_ACCESSDENIED))

The code under the button is as follows:

// connect the to server
ManagedComputer computer = 
    new ManagedComputer("172.16.150.52",@"Administrator","secret");

// return if there is a problem
if (computer.Services["MSSQLSERVER"] == null)
{
    PageErrorMessage = "Bad or missing service \"MSSQLSERVER\"";
    return;
}

// get the SQL Server Service
Service sqlServer = computer.Services["MSSQLSERVER"];

// is the server running?
if (sqlServer.ServiceState == ServiceState.Running)
    sqlServer.Stop();

// wait for it to stop completely
int timeout = 0;
while (sqlServer.ServiceState != ServiceState.Stopped || timeout <= 60)
{
    Thread.Sleep(1000);
    sqlServer.Refresh();
    timeout++;
}

if (timeout > 60)
{
    PageErrorMessage = "Stop operation has timed out after 60secs";
    return;
}

// start it again!
sqlServer.Start();

The IP address, username & password are 100% correct. Does anyone know why this would throw an AccessDenied exception?

  • 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-05-27T15:53:57+00:00Added an answer on May 27, 2026 at 3:53 pm

    It sounds like you’re missing the UAC. Often, to do system-wide tasks such as rebooting, shutting down (and probably also starting/stopping services), you have to get the elevated priviliges, which includes obtaining a token, etc.

    Take a look at this article – http://www.codeproject.com/KB/vista-security/UAC__The_Definitive_Guide.aspx – it has helped me on a few occasions.

    But http://www.codeproject.com/KB/vista-security/ElevatedPrivilegesDemand.aspx might also be helpful.

    I have only ever done this client side myself – I don’t know how it works when running on a server. For that, you might want to take a look at: http://blogs.msdn.com/b/lightswitch/archive/2011/04/07/how-to-elevate-permissions-in-server-code-ravi-eda.aspx

    And if it’s not code, but configuration, take a look at this: http://www.lansweeper.com/kb/WMI-Access-is-denied.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a SharePoint web part which will have a simple ASP.NET form.
I'm trying to create a simple web service application where I can retrieve a
I'm relatively new to utilizing web services. I'm trying to create one that will
I'm trying to create a web form that contains checkboxes, among other input elements,
I've just written (in Perl) a simple web service that displays a web form
I'm trying to create a simple redirect on this form. The form sends an
I'm trying to create a simple web filtering app in python. The way I
When trying to create a simple service to return a simple JSON string by
I'm trying to send a simple POST request to a REST web service and
I am trying to create a simple web app using Python on GAE. The

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.