| DotNetFirebird Using Firebird SQL in .NET. |
|
Home
Features
Download
Documentation
FAQ
Tools and Code
About
Blog
|
Monday, July 10, 2006
Is it possible to stop/start remote firebird service using Firebird ADO.NET Provider?However, you can use this simple code: ServiceController sc = new ServiceController("FirebirdGuardianDefaultInstance"); // or "FirebirdServerDefaultInstance" if you are not using Guardian
Console.WriteLine("Stopping service...");
sc.Stop();
while (sc.Status != ServiceControllerStatus.Stopped)
Thread.Sleep(100);
Console.WriteLine("Service stopped.");
Console.WriteLine("Starting service...");
sc.Start();
while (sc.Status != ServiceControllerStatus.Running)
Thread.Sleep(100);
Console.WriteLine("Service started.");
You need to reference System.ServiceProcess.dll and add these usings: using System.ServiceProcess; using System.Threading; Comments:
As far as i understand, it would stop/start the local service, not the remote one, to do such trick with remote service, one should have enough rights to control Service Manager of remote Computer, usually it's not the case
Yes, you are right.
If you want to stop remote service on a remote computer using this constructor: public ServiceController( string name, string machineName ); you need the appropriate rights. You can also use WMI where you could have the chance to specify the credentials or build a helper service that reside on the target computer and will expose this functionality via remoting, web service or something else. Blog comments are closed.
Previous
Archives
Copyright © 2005 - 2007 DotNetFirebird |