I have a desktop app that has SQL Server Express runing on the client's desktop only when the program is running. How can I start the service from code?
Printable View
I have a desktop app that has SQL Server Express runing on the client's desktop only when the program is running. How can I start the service from code?
One easy way is to call "NET START service name".
You can put it in a bat file and start that process or start the cmd.exe and pass the arguments.
There is no way to call it in VB?
Silly me:
Add a ServiceController from the toolbox and on the form add this:
Code:If ServiceController1.Status = ServiceProcess.ServiceControllerStatus.Stopped Then
ServiceController1.Start()
End If
Like you did or as I posted using System.Diagnostics.Process.StartQuote:
Originally Posted by tylerm
y when i use this method, got error shows "Service name contains invalid characters, is empty, or is too long (max length = 80)." What is this error means :sick:Quote:
Originally Posted by tylerm
You didnt provide a serice name for it to start/stop.