如何使用C#在命令提示符下运行特定命令 [英] How to run specific command in Command prompt using C#

查看:70
本文介绍了如何使用C#在命令提示符下运行特定命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用以下命令从命令提示符处重新启动Sql Server:

I want to restart Sql server from command prompt using these following command:

NET STOP MSSQL$SQLExpress
NET START MSSQL$SQLExpress


我发现这些以下代码可以启动cmd进程.但是我不知道如何使用c#
在命令提示符下运行以上命令


I have found these following code which start cmd process. But i have no idea how to run above command on command prompt using c#

Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Application.StartupPath.Trim() + @"\command\cmd.exe";
psi.Arguments = "NET STOP MSSQL$SQLExpress";
p.StartInfo = psi;
p.Start();


请帮助我重新启动SQL Server.
在此先感谢


please help me to restart SQL server.
Thanks in advance

推荐答案

SQLExpress NET START MSSQL
SQLExpress NET START MSSQL


SQLExpress
SQLExpress


我发现这些以下代码可以启动cmd进程.但是我不知道如何使用c#
在命令提示符下运行以上命令


I have found these following code which start cmd process. But i have no idea how to run above command on command prompt using c#

Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Application.StartupPath.Trim() + @"\command\cmd.exe";
psi.Arguments = "NET STOP MSSQL


SQLExpress" ; p.StartInfo = psi; p.Start();
SQLExpress"; p.StartInfo = psi; p.Start();


请帮助我重新启动SQL Server.
预先感谢


please help me to restart SQL server.
Thanks in advance


这篇关于如何使用C#在命令提示符下运行特定命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆