2011-05-12 121 views
0

我在C#.NET 3.5中编写了一个Windows服务。 它自动启动并以本地系统用户身份运行(不需要登录)。注销时在Windows服务中运行批处理文件

如果我通过调用Process.Start()对我的服务运行Shutdown-Batch-File(shutdown -s -t 30),那么直到我登录到Windows时才会发生任何事情。所以它等待登录然后开始批处理。

是否有可能在注销状态下运行此批处理?

问候

回答

0

有名为Allow Interact With Desktop每个服务应用程序应该为您服务设置True到能够运行Shutdown-Batch-File属性。

在这些链接看看:

Interact With Desktop when Installing Windows Service

Allow service to interact with desktop in C#

+0

感谢您的answer.i已将其设置为true。但没有任何反应:( – MariusK 2011-05-12 09:15:30

+0

http://www.codeproject.com/KB/system/xyntservice.aspx是非常相似的东西你想 – fardjad 2011-05-12 17:17:34

+0

我明白了!它是防火墙-.-(我正在测试日志记录,关闭模式从我的路由器以外):D感谢您的帮助! – MariusK 2011-05-13 07:51:41

0

你检查,以确保这不是权限问题?即使服务以管理员身份运行,也就是说它工作吗?

您可能还想尝试在此问题中提到的关闭替代方法how-to-shutdown-the-computer-from-c#

+0

是的,我已经检查过(使用管理员) 也许批处理不能在注销时启动?似乎该批处理只会排队等待登录。 我会尝试通过直接shutdown.exe调用关闭的另一种方法,谢谢 any1 else有一个想法? – MariusK 2011-05-12 11:58:12

相关问题