我怎样才能运行Windows应用程序之前,用户登录? [英] How can I run a Windows application before a user has logged in?

查看:142
本文介绍了我怎样才能运行Windows应用程序之前,用户登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  <一href="http://stackoverflow.com/questions/6706819/how-can-a-wpf-application-be-launched-before-i-logon-to-windows">How可在WPF应用程序启动之前,我登录到Windows?

我已经用C#编写一个应用程序。我想运行我登录到Windows操作系统之前,应用程序(Windows OS pre-加载后)。 我该怎么办呢?

解决方案

的方式做,这是创建一个Windows服务,而不是一个应用程序。由于服务的没有的用户模式应用程序,允许他们即使登录的用户没有运行。

不过,这有其他的注意事项。大多数开发人员只了解了上面的,认为他们需要写一个Windows服务。这是不正确的:在现实中,它的非常的罕见的,你有没有实际需要编写的其中之一。正如上面提到的,他们的没有的用户模式应用程序,因此无法显示任何类型的用户界面。它们被设计的的在后台和实例上运行,其中用户不需要与之互动以任何方式,除[很少]停止和启动它们。

如果你已经有一个用户界面,一个普通的应用程序,然后创建一个Windows服务是给你的 不是一个选项。应用程序将无法移植到一个服务,你会回来的询问看似无法解释的行为,系统崩溃,以及无法做各种事情半打问题。服务是的没有的一个替代品的应用程序:这是一个完全不同的产品,需要一个完全不同的设计方法

所以,你有什么选择?好了,基本上没有什么。视窗是一个多用户操作系统。有没有办法运行一个用户模式应用程序的无需用户登录的。你能做的最好的事情就是你的应用程序添加到所有用户帐户共享的启动文件夹,然后将机器配置为自动登录一个特定的用户在启动时。这样一来,绝不会有计算机正在运行没有用户登录的时间,因此不运行你的应用程序也是如此。

为了做到这一点,你需要配置组中的计算机,这将需要你有他们的管理权限,并不会属于客户,你没有自己的电脑(如机器上工作政策)。这实际上是一件好事,因为这是的非常的设计很糟糕用于一般用途的应用程序。

提出更多的问题关于我们的姊妹网站专为系统管理员,服务器故障设置组策略了。

Possible Duplicate:
How can a WPF application be launched before I logon to Windows?

I have written a application in C#. I want to run my application before logging into Windows OS (after Windows OS pre-loading). How can I do that?

解决方案

The only way to do this is to create a Windows Service instead of an application. Since services are not user-mode applications, they are allowed to run even when no user is logged in.

However, this has other caveats. Most developers learn only the above and think that they need to write a Windows Service. This is incorrect: in reality, it is quite rare that you ever actually need to write one of these. As mentioned above, they are not user-mode applications and therefore cannot show any type of user interface. They are designed only to run in the background and for instances where the user does not need to interact with them in any way, other than [rarely] stopping and starting them.

If you already have a regular application with a user interface, then creating a Windows Service is not an option for you. Your application will not port to a service, and you'll be back asking half a dozen questions about seemingly unexplained behavior, system crashes, and the inability to do various things. A service is not a replacement for an application: it's an entirely different product that requires a completely different design methodology.

So what are your options? Well, basically nothing. Windows is a multi-user operating system. There is no way to run a user-mode application without a user logged in. The best thing that you can do is to add your application to the "Startup" folder shared by all user accounts, and then configure the machine to automatically log in a particular user when it starts up. That way, there will never be a time that the computer is running without a user logged in, and therefore without your application running as well.

In order to do this, you'll need to configure Group Policies on the computers, which will require you to have administrative access to them and will not work on computers which you do not own (such as machines that belong to customers). That's actually a good thing, because this is extremely poor design for an application intended for general use.

Ask more questions about setting up Group Policies over on our sister site designed for system administrators, Server Fault.

这篇关于我怎样才能运行Windows应用程序之前,用户登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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