在 Windows 启动时运行程序
我想知道是否有人可以向我解释如何让我的程序在启动时运行? 我的程序是一个带有小型 WPF UI 的 C# WCF,必须在服务器上运行,并且我需要确保该程序将在服务器重新启动或出于任何其他原因时启动。
我环顾四周,看来我必须使用注册表项,但我不太熟悉如何使用注册表项,有人可以向我解释一下如何使用它。我正在使用 VS2010 创建安装程序,我想在安装时设置注册表项:)
PS 我不希望该应用程序成为 Windows 服务,而且我不能只是将其放在启动文件夹中user(如果服务器重启后没有人登录怎么办?)
I was wandering if someone could explain to me how I could make my Program run on startup?
My program is a C# WCF with a small WPF UI that has to run on a server, and I need to make sure that the program will start whenever that server restarts or for whatever other reason.
I have had a look around, and it appears that I have to use the registry keys but I am not to familiar with how to use registries keys, could someone please explain to me how I could use this. I am using VS2010 with creating an Installer and I would like to set the registry key when it installs :)
P.S. I don't want the application to be a Windows Service, and I can't just put it in the startup folder for a user(cause what if the server restarts and no one logs in?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加要运行的内容:
http://www.geekpedia.com/ tutorial151_Run-the-application-at-Windows-startup.html
更新:再考虑一下之后,这可能不会对您有帮助,因为您的方法似乎从根本上来说是有缺陷的。仍然需要有人登录才能运行 UI。解决方案如何:
将服务推回 Windows 服务(正如其他人所建议的那样)。对于 WPF UI 部分,将其与托管 WCF 服务的 exe 分离到其自己的项目中。只需公开另一个服务端点合约,UI 可使用该合约来管理/监视服务。
这为从不同的机器监控服务器打开了大门。此外,您不必担心多个人同时登录服务器(在许多环境中这是一种可能的情况)并启动服务主机的多个实例。
Add something to run:
http://www.geekpedia.com/tutorial151_Run-the-application-at-Windows-startup.html
UPDATE: After thinking about this some more, this probably won't help you because your approach appears to be fundamentally flawed. Somebody still needs to log in order for a UI to run. How about this for a solution:
Push the services back to a windows service (as everyone else has suggested). For the WPF UI piece, separate that from the exe that hosts the WCF services into its own project. Just expose another service endpoint contract that the UI can use to manage / monitor the service.
That opens up the door to being able to monitor the server from a different machine. Also, you don't have to worry about more than one person logging into the server at the same time (a likely scenario in many environments) and spinning up multiple instances of the service host.