.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> System Process >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Running a program at startup

Posted By:Ravi Ranjan Kumar       Posted Date: June 30, 2011    Points: 40    Category: System Process    URL: http://www.dotnetspark.com  

This Code Snippet enable you to learn how to run program at startup of windows.
 

You need to use the Registry for running a program at startup. You can use the RegistryKey class that's in the System.Win32 namespace. The following code shows how to do this:

RegistryKey rk = Registry.CurrentUser;
RegistryKey StartupPath;
StartupPath = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
if (StartupPath.GetValue("ProjectName") == null)
{
    StartupPath.SetValue("ProjectName", Application.ExecutablePath, RegistryValueKind.ExpandString);
}
Note: RegistryKey is in the System.Win32 namespace, hence don't forget to import it.

I've also posted this tips as a answer in CP. take a look at given link 

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend