运行批处理文件中的Windows服务,同时注销批处理文件、Windows

2023-09-07 10:32:41 作者:再次、釋懷

我在C#.NET 3.5编写了一个窗口服务。 它会自动启动并运行作为本地系统用户(没有在日志中需要)。

I wrote a windows service in C# .NET 3.5. It starts up automatically and runs as Local System User (no log in required).

如果我运行一个关机,批处理文件(关机-s -t 30)我的服务调用的Process.Start(),没有任何反应,直到我登录到Windows。所以它等待日志记录,然后开始批量。

If i run a Shutdown-Batch-File (shutdown -s -t 30) with my service by calling Process.Start(), nothing happens until i log in to windows. So it waits for logging in and then starts the batch.

是否可以运行这个批注销状态?

Is it possible to run this batch in logged off state?

问候

推荐答案

有名为每个服务应用程序允许与桌面交互应设置真为您服务,能够运行关闭-批处理文件

There is a property for each service application called Allow Interact With Desktop that should be set True for your service to be able to run Shutdown-Batch-File.

看看以下链接:

安装时与桌面交互的Windows服务

允许服务与桌面C#互动

 
精彩推荐
图片推荐