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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:46:59+00:00 2026-05-10T17:46:59+00:00

Ok so part two of I have no will power experiment is: Summary Question

  • 0

Ok so part two of I have no will power experiment is:

Summary Question – Is there a way to set the CanStop property on a windows service dynamically?

Whole Spiel – I have a service that is currently checking and killing processes (IE Games) I have told it to if it’s day I’m not allowed. Great. I set the CanStop to false so that I can’t just kill the service if I give into the addiction. I have a program that will have a password check (Someone else enters the password) that will stop the service if the password is correct. (If I have serious withdrawals) Problem is using the ServiceController class.

Far as I can tell, ServiceController just is a decorator (yah design patern guess) and so I have no way to get at the actual service it represents. First attempt was Property Info, but I was too dumb to realize what that would be pointless. Second was Field Info because I thought there might be a private field that ‘represents’ the service. As you might guess, both failed.

Any ideas?

EDIT 1 I’d like to avoid having the CanStop value somewhere I can get to it easily like a config file or registry. So I am attempting, though not successfully, to make this completely handled in program.

New (Failed) Attempts:

ManagementObject service; ManagementBaseObject stopService;

service = new ManagementObject(‘Win32_Service.Name=’StopProgram”);

stopService = service .InvokeMethod(‘StopService’, null, null);

Not sure this did anything. I assume it couldn’t stop because of the CanStop situation.

  • 1 1 Answer
  • 4 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. 2026-05-10T17:46:59+00:00Added an answer on May 10, 2026 at 5:46 pm

    The ‘CanStop’ is a attribute of the services registration in the windows service control manager. You can’t change it mid-stride.

    And, of course, if you’re smart enough to write your own service then you’re smart enough to bring up task-man and simply kill the service process. CanStop will not prevent you from pulling the rug out from under the service. CanStop only tells the service control manager not to send ‘Stop’ commands to the service.

    If you want to allow something to pass then use a global event to enable/disable the checking the service does — or just remove the games from the PC! 🙂

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

Sidebar

Related Questions

This is two part question: I have two stored procedures: sp1 & sp2. If
I have a web service that requires a two part query to fully get
I have a two part question concerning Android. The first, is if I have
I have a two part question. The first I think I have an okay
Is there any way to have two keyboards on the screen at once? I
I have two separate applications (both part of the same system) that share a
I have two actions in my controller which are sharing part of logic responsible
I have two MAIN DIVs inside a DIV which is a PART of the
Let's say i have two tables in db: Car and Part. Car owns arbitrialy
I have a TabPanel, where the TabPanel contains two parts, one part has details

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.