开发者

Run Program At Windows StartUp

开发者 https://www.devze.com 2023-04-05 19:59 出处:网络
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 prog

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 Servi开发者_运维百科ce, 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?)


Add something to run:

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());

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消