Alex Rivera | Logout

how do start/stop services using net stop command in c#

Asked 2009-07-11T05:04:31.530
10

how do start/stop services using net stop command in c# for example

Dim pstart As New ProcessStartInfo
Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.System)
Dim p As New Process
pstart.FileName = path + "\cmd.exe"
pstart.UseShellExecute = False
pstart.CreateNoWindow = True
pstart.WorkingDirectory = path
pstart.FileName = "cmd.exe"
pstart.Arguments = " net start mysql"
p.StartInfo = pstart
p.Start()

i have used process class but no result

Edit
Report

1 Answer

3

You need to pass the "/c" switch to cmd.exe

pstart.Arguments = "/c net start mysql"
answered 2009-07-11T05:16:08.633

Your Answer