Restart a Service

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
 
P

pvong

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

Michael Nemtsev [MVP]

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>
 
P

pvong

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top