C#中启动sql服务的一段简单代码
System.Diagnostics.ProcessStartInfo libt = new System.Diagnostics.ProcessStartInfo();
libt.FileName = "cmd.exe";
libt.Arguments = "/c net start mssql$db2005"; // "c" 后面的是Doc语句
libt.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //将窗体模式设为隐藏模式
System.Diagnostics.Process.Start(libt);
libt.FileName = "cmd.exe";
libt.Arguments = "/c net start mssql$db2005"; // "c" 后面的是Doc语句
libt.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //将窗体模式设为隐藏模式
System.Diagnostics.Process.Start(libt);
附注:
运行环境 :SQL2005 、VS2005
通过dos命令启动服务