473,395 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Restart a Service

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...indows-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
Oct 2 '08 #1
4 1273
Have you set reference to SystemServiceProcess.dll in the project?

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:u%****************@TK2MSFTNGP04.phx.gbl...
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...indows-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

Oct 2 '08 #2
Can you help me out with that? I'm a newbie at this. How do you set a
reference to the dll?
"Norman Yuan" <Fa******@FakeEmail.Notwrote in message
news:uc**************@TK2MSFTNGP03.phx.gbl...
Have you set reference to SystemServiceProcess.dll in the project?

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:u%****************@TK2MSFTNGP04.phx.gbl...
>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...indows-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


Oct 2 '08 #3
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
pCan you help me out with that? I'm a newbie at this. How do you set
pa reference to the dll?
p>
p"Norman Yuan" <Fa******@FakeEmail.Notwrote in message
pnews:uc**************@TK2MSFTNGP03.phx.gbl...
p>
>Have you set reference to SystemServiceProcess.dll in the project?

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:u%****************@TK2MSFTNGP04.phx.gbl...
>>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...1/start-and-st
op-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

Oct 2 '08 #4
Thanks guys! That worked perfectly.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:90**************************@msnews.microsoft .com...
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

pCan you help me out with that? I'm a newbie at this. How do you set
pa reference to the dll?
pp"Norman Yuan" <Fa******@FakeEmail.Notwrote in message
pnews:uc**************@TK2MSFTNGP03.phx.gbl...
p>
>>Have you set reference to SystemServiceProcess.dll in the project?

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:u%****************@TK2MSFTNGP04.phx.gbl.. .

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...1/start-and-st
op-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


Oct 3 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: nek | last post by:
Greetings, I'm using DB2 WSE V8.1 FP2 on W2K SP4. Right clicking 'properties' from 'DB2 - DB2' service (Admin Tools -> Services), then selecting 'recovery' tab allows me to select computer's...
5
by: LL | last post by:
Hi, I use Applicaiton lever variable like this: Application = xxx; Do I need to restart the WWW service every time to reset it? I also have several Session variables. When Session_End event...
0
by: felecha | last post by:
Is there a way to write a Service so that it will fail? I'm working on a Service written in VB.Net, that supports an application we are building, and I want to make sure that it can restart...
6
by: Leonardo Curros | last post by:
Hello, I would like to know what's the best way to restart one service. I would like to do it from the service itself. Is this possible? I try it with ServiceController.stop()...
3
by: Matt | last post by:
Is there an 'easy' way to have a service stop and restart itself? I currently have a seperate service running who's job is to watch the other service and restart it if there is a problem... can I...
2
by: Tedmond | last post by:
Dear all, I wrote a service by C# but I found the service is not quite stable. I want to add some code that refresh or restart the service itself for a fixed period. Does anyone know how to...
8
by: kenneth fleckenstein nielsen | last post by:
hi guru's I want to restart my webservice when ever it throws an exception that isn't cought. can i do that by web.config or iss or how ??
1
by: Sergey Krutous | last post by:
Can you please help me to resolve the following issue: I developed a windows service. At start up (I have overriden OnStart method) it connects to a web service and if the connection fails the...
0
by: Emanuele | last post by:
I have write a program using MS Visual studio C++ 7.0 (platform Windows XP professional). I'm not using .NET. This program save data in a SQL server 2000 database using ADO. Everything works...
8
by: =?Utf-8?B?TWlrZVo=?= | last post by:
How Can Windows Service Application Reatarts itself? Thanks.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.