运行程序在Windows启动 [英] Run Program At Windows StartUp

查看:132
本文介绍了运行程序在Windows启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是游荡,如果有人可以向我解释,我怎么可能让我的程序在启动时运行?
我的程序是用C#WCF与具有在服务器上运行一个小的WPF UI,我需要确保该程序将启动每当服务器重新启动或任何其他原因。

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.

我有一个看看周围,看来,我必须使用注册表项,但我不熟悉如何使用注册表键,可能有人请向我解释我如何使用这个。我使用VS2010与创建一个安装程序,我想设置注册表项时,它会安装:)

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。我不希望应用程序是一个Windows服务,我不能只把它放在启动文件夹中为用户(原因是什么,如果在?在服务器重新启动,没有人日志)

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?)

推荐答案

添加的东西来运行:

http://www.geekpedia.com/tutorial151_Run-the-application-at-Windows-startup.html

RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

rkApp.SetValue("MyApp", Application.ExecutablePath.ToString());



更新:想着这之后更多一些,这可能不会因为你的方法似乎是根本性的缺陷帮你。有人仍然需要登录为了使UI运行。这个怎么样的解决方案:

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:

按服务返回一个窗口服务(如其他人曾建议)。对于WPF UI件,分离,从承载WCF服务纳入自己的项目的exe文件。刚刚揭露的UI可以用来管理/监控服务的另一个服务端点合同。

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.

这篇关于运行程序在Windows启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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