通过sc.exe停止并启动c#中的Windows服务 [英] stop and start Windows Services in c# by sc.exe

查看:308
本文介绍了通过sc.exe停止并启动c#中的Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

这是我的代码:



ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.FileName =sc.exe;

startInfo.Arguments =\\192.168.0.165 start SpyService;

Process.Start(startInfo);



如何在c#中通过sc.exe停止和启动Windows服务。

我写这段代码但是我的应用程序无法运行。

Hi all.
this is my Code :

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "sc.exe";
startInfo.Arguments = "\\192.168.0.165 start SpyService";
Process.Start(startInfo );

how can I stop and start Windows Services by sc.exe in c# .
I write this code but my application can not be run .

推荐答案

应用程序无法运行肯定不是正确的描述失败。

因此,我只能给出一些建议:

- startInfo.Arguments = @ \\192.168.0.165启动SpyService;

- 以管理员身份运行程序

- 关闭防火墙
"application can not be run" is surely not the correct description of the failure.
Because of that, I can give some suggestions only:
- startInfo.Arguments = @"\\192.168.0.165 start SpyService";
- run your program as administrator
- switch off firewalls


这篇关于通过sc.exe停止并启动c#中的Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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