用process类 如何关闭IIS 或者 发送dos命令

zhizlm 2009-12-17 12:20:17
1,process能直接关闭iis服务吗?

2,如果发送dos命令 net stop w3svc 怎么才能在后台执行?

...全文
144 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
gomoku 2009-12-17
  • 打赏
  • 举报
回复
using (ServiceController sc = new ServiceController("w3svc"))
{
sc.Stop();
}
  • 打赏
  • 举报
回复
p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("net stop w3svc");// 向cmd.exe输入command
p.StandardInput.WriteLine("exit");
sh1618 2009-12-17
  • 打赏
  • 举报
回复
顶一个 希望楼下解答!

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧