Click here to Skip to main content
15,903,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am looking to load an application in the background when windows loads, do it's purpose and then close. I have looked on google and found alot, but not alot that is useful to me.

Registeries are mentioned alot and to be honest that isn't the way I would like to go if at all avoidable! It is a bit out of my depth and I don't want to be changing things that could cause issues with the system!

Would it be better to create the app as planned, install to windows and then set it as run on startup. Or is there a more eligant way of doing this?

Thanks in advance,

Dan
Posted

I'd build a windows service and set it to start automatically:

http://msdn.microsoft.com/en-us/library/d56de412%28v=VS.100%29.aspx[^]
 
Share this answer
 
Comments
DanHodgson88 25-Oct-11 8:37am    
Looks interesting cheers for that
Amir Mahfoozi 25-Oct-11 8:38am    
The only way, other than manipulating registry, is this +5
Mantu Singh 25-Oct-11 9:13am    
Use registry just set the installer to do that entry for the application you need to run its simple enough or use Microsoft.Win32.Registry class for you purpose.....
The easiest way would just be to add a shortcut to your application in the Startup directory of Windows.

e.g. C:\Documents and Settings\All Users\Start Menu\Programs\Startup

As you mentioned, the registry is another way to do this. While you're correct & you need to be a bit careful in the registry, it's honestly not that difficult.

* Start -> Run -> regedit
* Expand the registry keys until you find HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
* Right mouse on the 'Run' key and choose 'New -> String Value'
* A value will be created on the right hand side called 'New Value #1'
* Double click this, enter the full path to your application in the 'Value Data' text box

That's it - You're done!

I wouldn't really recommend a windows service for what you need to achieve, the above 2 methods are the best to 'run something, then exit'. Windows services start and continue running in the background, they are there to provide functionality for other applications and services. That's not what you're trying to do.
 
Share this answer
 
Comments
Mantu Singh 25-Oct-11 9:14am    
Agree totally doing simple entry in registry is better than loading a service in the system my 5!
jim lahey 25-Oct-11 9:27am    
You are of course correct in that it can be done via a registry entry, but quoting the OP: "load an application in the background when windows loads, do it's purpose and then close". I understand his requirement is for the app to do it's stuff unattended and then close, or in a windows service it would be ServiceBase.OnStop()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900