Results 1 to 4 of 4

Thread: How to code for a stop and start of a windows service ?

  1. #1
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2018
    Posts
    3
    Rep Power
    0

    How to code for a stop and start of a windows service ?

    Hello,

    I am new with C# and know just the basics.

    I would like to create a command line executable where the program can stop and start a windows service through a windows domain account ?

    Is that possible ?

    We always get tickets to restart a windows service on a windows server. So, it will be nice if i create am executable or msi and give to the user, so she double clicks and stops and restart the service for her and acknowledging service status through a pop up.

    Thoughts ? Thanks for your help,

  2. #2
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Posts
    1,956
    Rep Power
    151
    The ServiceController class is what you're looking for. It's a component so that means that you can add an instance to a form in the designer and configure it there. You can, of course, create an instance in code if you prefer.

  3. #3
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2011
    Location
    Lansing, MI; USA
    Posts
    140
    Rep Power
    98
    There's also a Project Type just for making a Windows Service program:

    WindowsService.png
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

  4. #4
    .NET Framework
    .NET 4.5
    Join Date
    Apr 2011
    Posts
    1,956
    Rep Power
    151
    Quote Originally Posted by JuggaloBrotha View Post
    There's also a Project Type just for making a Windows Service program:
    But that's for creating an actual service, where the request here is for a program that can stop and start a service.

Similar Threads

  1. Question Windows Service does not appear under services.msc is called
    By aindrea in forum Windows Services
    Replies: 2
    Last Post: 06-05-2018, 6:11 AM
  2. connect windows service to sql
    By hamid.abbaszadeh.mail in forum Windows Services
    Replies: 3
    Last Post: 10-30-2016, 9:10 PM
  3. web service + win service
    By ytzkey in forum Windows Services
    Replies: 1
    Last Post: 08-08-2014, 5:12 AM
  4. Replies: 0
    Last Post: 10-25-2011, 10:31 AM
  5. Question Where to put my code in a Windows Service skeleton
    By bradwoody in forum Windows Services
    Replies: 2
    Last Post: 09-23-2011, 10:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •