Restart a Service

  • Thread starter Thread starter pvong
  • Start date Start date
P

pvong

Trying to do this in VB.NET

All I want to do is restart a service called MxRtmSrvr. I tried this:
http://www.eggheadcafe.com/community/aspnet/14/10012971/start-and-stop-windows-se.aspx

This is my code page. For the line: Dim Controller as New Service
Controller, I'm getting the error message that "ServiceController" is not
defined. As you can see, I imported System.ServiceProcess.
Why am I getting this error message?

Also, I imported Threading. I want a 3 sec pause between stop and start.
Is Thread.Sleep(3000) the right way to do this?
Thanks!



-------------------------------------------------------
Imports System.Data, System.Data.SqlClient, System.Threading,
System.ServiceProcess
Partial Class Database
Inherits System.Web.UI.Page
Protected Sub MxRtmSrvrB_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MxRtmSrvrB.Click
Dim controller As New serviceController
controller.ServiceName = "MxRtmSrvr"
controller.Stop()
Thread.Sleep(3000)
controller.Start()
End Sub

End Class
 
Can you help me out with that? I'm a newbie at this. How do you set a
reference to the dll?
 
Hello pvong" phillip*at*yahoo*dot*com,

Right mouse click on your web project, and select Add reference

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour
:: http://twitter.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


p> Can you help me out with that? I'm a newbie at this. How do you set
p> a reference to the dll?
p>
p> p>
 
Thanks guys! That worked perfectly.


Michael Nemtsev said:
Hello pvong" phillip*at*yahoo*dot*com,

Right mouse click on your web project, and select Add reference

---
WBR, Michael Nemtsev [Microsoft MVP] :: blog:
http://spaces.live.com/laflour :: http://twitter.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

p> Can you help me out with that? I'm a newbie at this. How do you set
p> a reference to the dll?
p> p>
 
Back
Top