473,324 Members | 2,166 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,324 software developers and data experts.

System.ServiceProcess platform issues

I'm trying to write an application that will periodically check a server
for certain services and, if they are not running, attempt to start them.

I'm using System.ServiceProcess and have no trouble detecting which
services are up and which are stopped, regardless of what platform my
application is running on.

However, when I try to start services, success is very intermittent. As far
as I can tell, running on XP or 2000 makes it impossible to start a service
on NT4 servers, but running on NT4 it sometimes works.

Is there a known OS issue that may be preventing this? My restart script in
VB (I have also tried using C# with the same results) is:
Public Function StartStopped(sServer as String, sService as String) as
Boolean

Dim oServices as New System.ServiceProcess.ServiceController()
Dim oService as System.ServiceProcess.ServiceController()

oServices.MachineName = sServer

For Each oService in oServices.GetServices()
if oService.ServiceName = sService Then
oService.Start()
oService.oServiceToStart. _
WaitForStatus(ServiceControllerStatus.Running, _
System.TimeSpan.FromSeconds(15.0))
if oService.ServiceControllerStatus = _
ServiceControllerStatus.Running Then
StartStopped = True
Exit Function
else
StartStopped = False
Exit Function
end if
end if
Next

End Function
Nov 20 '05 #1
0 813

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

Similar topics

0
by: Erick | last post by:
Hi, I have a Installer class used to install my windows service, it was created by the wizard that is in the VS, I just whent into the properties and set up the properties of the ServiceInstaller...
1
by: Tom J | last post by:
What do I have to do to get System.ServiceProcess.ServiceController.ExecuteCommand(int) to work? I have written a service that overrides OnCustomCommand to handle commands sent to it. If I...
6
by: Pawel Janik | last post by:
Hello, I wrote a system service, whis is located in assembly called "s1.exe". But i like to install this service twice. Problem starts, when service starts....a service code loks like this: ...
1
by: Tom | last post by:
I've googled, and read, and stripped out code, and rewritten code, and still can't get a System.Threading.Timer to work. (I hereby publicly admit that I'm a failure here...) Could someone please...
2
by: John Chrisman | last post by:
I get the above error message as well as a complaint about the RunInstallerAttribute not being found when compiling the following code. This couldn't be any simpler and I see examples on the web...
1
by: SQLScott | last post by:
I am using the System.ServiceProcess methods to look at the status of several services. It will tell me if it is Stopped, Started, etc. But how do I tell if a service is Not Responding, or Hung?...
1
by: SenthilVel | last post by:
Hi We use System.ServiceProcess.ServiceController class is used to get the list of windows services installed in a particular machine. Also we use...
5
by: Philip Wagenaar | last post by:
I have a Windows Form application that monitors a directory using the System.IO.FileSystemWatcher. On the event created I run a sub that sends an xml file over http to a service. When I copy...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.