简体   繁体   English

注销时,为什么应用程序在Windows上作为系统帐户运行

[英]Why does an application running as the system account on windows when logging off

I have ac# application which is launched under the System account on a machine and presents some dialogs to a user. 我有一个ac#应用程序,它在一台机器上的System帐户下启动,并向用户提供一些对话框。 When a regular user logs off the application is terminated as well. 当常规用户注销时,应用程序也会终止。 I would have thought that since its running under the system account it would continue to run despite the user not being logged in. 我本以为,由于它在系统帐户下运行,它会继续运行,尽管用户没有登录。

Any info on why this happens would be appreciated. 有关为什么会发生这种情况的任何信

Is your application a service? 您的应用程序是服务吗? It sounds like what you want is a service. 听起来你想要的是一种服务。 Note that you can run any process as any user, but that doesn't make it a service. 请注意,您可以像任何用户一样运行任何进程,但这不会使其成为服务。 If your process is implemented as a service, then it will continue running even with no users logged in. 如果您的流程是作为服务实现的,那么即使没有用户登录,它也会继续运行。

If you want your app to keep running after the user has logged off (eg to maintain state for as long as the computer is running), you need a service. 如果您希望应用程序在用户注销后继续运行(例如,只要计算机正在运行,就保持状态),您需要一项服务。 However, services are strongly discouraged from displaying UI. 但是,强烈建议不要显示UI。 If you need both long-running and UI, consider writing a service to store your data, and an application that runs each time a user logs in that shows UI and interacts with the service. 如果您需要长时间运行和UI,请考虑编写用于存储数据的服务,以及每次用户登录时运行的应用程序,该应用程序显示UI并与服务交互。

This is a security feature when a users session ends applications they invoked are terminated. 当用户会话结束他们调用的应用程序时,这是一项安全功能。 If you need an application to run outside of a users session you need a service however since its in its own session services cant "reach into" the users session with messages and such. 如果您需要在用户会话之外运行应用程序,则需要服务,因为它在其自己的会话服务中无法通过消息等“进入”用户会话。

您需要将应用程序作为Windows服务运行。

You will need to create your application as a windows service. 您需要将应用程序创建为Windows服务。 If your application displays dialogs then you would need to check the 'Allow service to interact with desktop' and run it under local system account. 如果您的应用程序显示对话框,则需要选中“允许服务与桌面交互”并在本地系统帐户下运行它。

However, a better approach would be to expose a queryable interface from your application using WCF or Remoting that you can display to users using a separate application. 但是,更好的方法是使用WCF或Remoting从应用程序中公开可查询的接口,您可以使用单独的应用程序向用户显示该接口。 If you want notifications from your app when no one is logged on then you might want to consider sending emails or posting events to a separate WCF/ Web Services/ Remoting endpoint. 如果您希望在没有人登录时从您的应用程序收到通知,那么您可能需要考虑发送电子邮件或将事件发布到单独的WCF / Web服务/远程处理端点。

Because the process was started by explorer.exe, it will be terminated when the user logs off regardless of what account it's running under. 因为该进程是由explorer.exe启动的,所以当用户注销时它将被终止,无论它在哪个帐户下运行。 That's simply the way windows works. 这就是Windows工作的方式。 To allow the process to continue running it needs to be a service or possibly started by the task scheduler. 要允许进程继续运行,它需要是一个服务,或者可能由任务调度程序启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows系统上注销用户后立即使系统进入睡眠状态 - Sending system to sleep right after logging off users on a Windows system 在带有“本地系统帐户”的“ Windows服务”下运行时,.NET Windows 7截屏不起作用 - .NET Windows 7 take screenshot not working when running under 'Windows Service' with 'Local System Account' 检测应用程序是否在系统帐户下运行? - Detect if application is running under system account? 运行Windows Phone 8应用程序时出现System.IO.FileNotFoundException错误 - System.IO.FileNotFoundException error when running Windows Phone 8 application 代码在控制台应用程序中有效,但在Windows Service中运行时不起作用 - Code works in a console application, but does not work when running in windows service 作为Windows服务运行时,MSMQ应用程序不处理排队的消息 - MSMQ Application does not process queued messages when running as Windows Service 系统锁定后运行Windows应用程序 - Running Windows Application after system locked 如何避免WPF应用程序在注销时不响应 - How to avoid WPF Application not Responding when logging off 在系统帐户下运行 Windows 计划任务时出错 - Error running a Windows Scheduled Task under System Account 如何在系统 Windows 用户帐户下启动控制台应用程序? - How to start a Console App as running under the System Windows user account?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM