问题描述
1)如何从C#Windows应用程序执行一条逗号行语句?
就像当我单击一个按钮时,cmd应该弹出并执行
"netsh advfirewall将privateprofile状态设置为关闭"
命令并以Windows形式显示结果?
我设法通过
启动CMD
1) How can we execute a commad line statement from C# windows application ?
Like When i click a button, cmd should pop up and execute
" netsh advfirewall set privateprofile state off "
command and show the result in windows form ?
I have managed to start CMD by
String statement= "netsh advfirewall set privateprofile state off";
System.Diagnostics.Process.Start("CMD.exe",statement);
但是该语句未执行..我得到的是一个cmd,其中的光标闪烁用于输入..
2)我们可以在管理员模式下启动应用程序吗?
即默认情况下,我的程序应在管理员模式下运行,而无需手动选择以管理员身份运行"
But the statement is not getting executed.. What i get is a cmd with cursor blinking for input..
2) Can we start an application in administrator mode ?
ie by default my program should work in administrator mode without manually choosing to "Run as Administrator"
推荐答案
System.Diagnostics.Process.Start("netsh", "advfirewall set privateprofile state off");
这篇关于Windows窗体中的CMD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!