Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to be allowed to start/stop windows service via ASP.NET page

How to be allowed to start/stop windows service via ASP.NET page

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-nettutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Herman T Instance
    wrote on last edited by
    #1

    Hi, I have a website with a Page that can start or stop a Windows Service. I get the error: Cannot open Service Control Manager on computer 'NZDB-TST'. This operation might require other privileges. My code:

        private void RunAlongServices(String ServiceName)
        {
    
            // Nog wel machinenaan aanpassen!!!
            ServiceController ctrl = new ServiceController(ServiceName, "NZDB-TST");
    
            if (ctrl.Status.Equals(ServiceControllerStatus.Stopped))
            {
                ctrl.Start();
            }
            else
            {
                ctrl.Stop();
            }
        }
    

    How to solve this issue, so the Windows service(s) can be started or stopped via de website?

    In Word you can only store 2 bytes. That is why I use Writer.

    L Y 2 Replies Last reply
    0
    • H Herman T Instance

      Hi, I have a website with a Page that can start or stop a Windows Service. I get the error: Cannot open Service Control Manager on computer 'NZDB-TST'. This operation might require other privileges. My code:

          private void RunAlongServices(String ServiceName)
          {
      
              // Nog wel machinenaan aanpassen!!!
              ServiceController ctrl = new ServiceController(ServiceName, "NZDB-TST");
      
              if (ctrl.Status.Equals(ServiceControllerStatus.Stopped))
              {
                  ctrl.Start();
              }
              else
              {
                  ctrl.Stop();
              }
          }
      

      How to solve this issue, so the Windows service(s) can be started or stopped via de website?

      In Word you can only store 2 bytes. That is why I use Writer.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      digimanus wrote:

      This operation might require other privileges.

      digimanus wrote:

      How to solve this issue, so the Windows service(s) can be started or stopped via de website?

      It appears you need to effect a change in privileges some way. What do you think the odds are that Microsoft has documented Privilege issues associated to using ServiceController? I guess those are pretty good odds. I also guess a simple Google search using the keyword MSDN along with other key words in your original post would turn up that documentation. Of course I am just guessing. Good luck.

      1 Reply Last reply
      0
      • H Herman T Instance

        Hi, I have a website with a Page that can start or stop a Windows Service. I get the error: Cannot open Service Control Manager on computer 'NZDB-TST'. This operation might require other privileges. My code:

            private void RunAlongServices(String ServiceName)
            {
        
                // Nog wel machinenaan aanpassen!!!
                ServiceController ctrl = new ServiceController(ServiceName, "NZDB-TST");
        
                if (ctrl.Status.Equals(ServiceControllerStatus.Stopped))
                {
                    ctrl.Start();
                }
                else
                {
                    ctrl.Stop();
                }
            }
        

        How to solve this issue, so the Windows service(s) can be started or stopped via de website?

        In Word you can only store 2 bytes. That is why I use Writer.

        Y Offline
        Y Offline
        Yusuf
        wrote on last edited by
        #3

        asp.net runs under IUser_machine_name account. Do you think it has permission to run services? Why do you want to start/stop service from asp.net anyway? Can't you solve it using other ways?

        Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

        H 1 Reply Last reply
        0
        • Y Yusuf

          asp.net runs under IUser_machine_name account. Do you think it has permission to run services? Why do you want to start/stop service from asp.net anyway? Can't you solve it using other ways?

          Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          Hello Yusuf, the reason I want this done via a website is to givethe real administrator of the website I am creating the possibility to control the services from the website. If it can be done indirectly with a command via the website it is allright too. So, do you know any better options?

          In Word you can only store 2 bytes. That is why I use Writer.

          Y 1 Reply Last reply
          0
          • H Herman T Instance

            Hello Yusuf, the reason I want this done via a website is to givethe real administrator of the website I am creating the possibility to control the services from the website. If it can be done indirectly with a command via the website it is allright too. So, do you know any better options?

            In Word you can only store 2 bytes. That is why I use Writer.

            Y Offline
            Y Offline
            Yusuf
            wrote on last edited by
            #5

            digimanus wrote:

            the reason I want this done via a website is to givethe real administrator of the website

            So are you targeting website administrators? what does web admin has to do with windows services?

            digimanus wrote:

            I am creating the possibility to control the services from the website.

            why? again I fail to see why web admin needs to interact with windows services. Windows services are meant to be running in the background on the server. Why do your application need to start/stop services. If there is a service your web app needs to interact, then make sure it is running. If needed you can change its properties from Services windows. If this is a windows service you wrote for the web application, then let it run automatically all the time. Alternatively, move the code to your code behind or write an assembly. If the target audience is Server Administrators then they need to remote login and perform what ever they want.

            Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups