Step One - Creating Functions
Warning: the source code given in this step concerns the programmatic editing of the system registry. If you edit the Window's Registry in the wrong way, by deleting certain keys or editing sensitive keys, your operating system may stop functioning properly. Always exercise caution when editing the registry.
The first step involves creating two separate functions, one for adding the application to the system start up and one for removing it from the system start up.
Create a void called EnableStartup using the following source code:
private void EnableStartup()
{
// Create the Registry Editing Object
Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
// Add this Application to the System Start up
registryKey.SetValue(Application.ProductName, Application.ExecutablePath.ToString());
}
The function just created, when called, will add the application to the system start up, as described in the code's comments. Now, finally make another void named DisableStartup and use the given source code:
private void DisableStartup()
{
// Create the Registry Editing Object
Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
// Disable the Application from Starting with Windows
registryKey.SetValue(Application.ProductName, false);
}
This function will disable the application from starting with Windows.
Conclusion
With the proper functions in place, all that is required to either enable or disable the application from starting with Windows is to call either the EnableStartup or the DisableStartup function. It is important to note however, that these functions should only be called with full prior knowledge and consent of the end user. Your application may be considered malware, spyware, or just plain annoying if it starts with Windows and the user doesn't want it to.
Note: I am not responsible for any malicious use or incorporation of this source code. Always give the user the option to either enable or disable this feature.
Published by James Cloud
I like to program and do basically anything that has to do with technology and computers. View profile
- How to Start Up a Business - Deciding What to Do!An article that provides four business ideas and opportunities. The ideas used will help you decide what type of business you want to set up, for example it might be a mail order business or perhaps an online business.
- Gearing-Up to Start-UpA start-up business is exciting. And when you're in the initial planning stages, it's easy to overlook any potential problems or concerns. Make sure you are really ready to embark on the entrepreneurial journey by f...
- Ways to Fund a Start-UpHere is a discussion of different sources of start-up capital for an aspiring entrepreneur.
- Hulu: Online Start-Up Entertainment Business Works to Outdo CompetitionHulu is a start-up in the entertainment media industry, looking for rapid success and acceptance by online television watchers. It is a current trend with a constant increase in demand to watch television on personal...
- Marketing Work for a Start Up BusinessI knew that I wanted to use my marketing background for a company that could benefit from it, so here's how I did it
- CSharp .Net Tutorial: Reading and Writing INI
- CSharp .Net Tutorial: Read / Write Registry
- How to Program with Assertions in Java Technology
- 10 Tips on Estimating Your Business Start Up Costs
- How to Make Your Computer Start Up Faster
- How To: Remove Programs Compiled from Source Code in Linux
- Security: A Must-have for Start-up Businesses



