473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to add startup program to windows?

Hi i googled this topic for a while now the closest ive been to finding the answer was a comment that said:
"Create new string value in [HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Run]

like "Notepad"="c:\windows\notepad.exe"."

i'm new to programming, what does the value in the "[]" mean and how would i add a string to it
Jan 15 '11 #1
3 6083
What does your program do?
How reliant is your program on starting up with windows?

The reason i ask is because that not many people like having 'junk' programs starting up with their computers.

Avoid adding startup commands to the registry unless required.

If you are making an update feature, look at alternatives such as checking when the program starts and give the user the option to add it to the registry.

If you make a simple add-on utility, such as a program that allows shortcut-key-combinations to programs, make it simple and place it in the 'C:\Documents and Settings\All Users\Start Menu\Programs\Startup\' folder.

Bad things happen in the registry, that can 'brick' a computer, avoid it if you can.

On another note, I'm working on a solution to your question.
Jan 16 '11 #2
Found a solution:

this is the code:
Expand|Select|Wrap|Line Numbers
  1. using Microsoft.Win32; //Don't forget this line
  2.  
  3. namespace WindowsFormApplication1
  4. {
  5. public partial class Form1 : Form
  6.     {
  7.         string myProgName = "My Program Name";
  8.         string myProgPath = @"My Program Path";
  9.  
  10.         //If your program has commandline arguments uncomment these lines:
  11.         //string myProgCommands = "CommandlineArguments";
  12.         //myProgPath = "\"" + myProgPath + "\" " + myProgCommands;
  13.  
  14.         private void WriteStartupKey()
  15.         {
  16.             RegistryKey rkeyRoot = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
  17.  
  18.             rkeyRoot.SetValue(myProgName, myProgPath, RegistryValueKind.String);
  19.             MessageBox.Show("Value Created");
  20.             rkeyRoot.Close();
  21.         }
  22.     }
  23. }
  24.  
To delete this key use this code:
Expand|Select|Wrap|Line Numbers
  1. RegistryKey rkeyRoot = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
  2. rkeyRoot.DeleteValue(myProgName);
  3. rkeyRoot.Close();
Jan 17 '11 #3
I agree with Samuel, you can add startup entries using startup folder easily.

Create registry entry under CURRENTUSER key to avoid permission issues.

Expand|Select|Wrap|Line Numbers
  1.  Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run").SetValue("Notepad", "c:\windows\notepad.exe", RegistryValueKind.String);            
  2.  
Jan 17 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Sheikko | last post by:
Hi all, i have an application and i wan to call another program into it, like notepad, so when i minimize the notepad, or maximize, it must rest in my application. thank you
2
by: andrewbb | last post by:
Occasionally I had been getting a 30-60 second delay when starting a Windows service written in .NET. Today I stumbled upon a way to reproduce it without fail: Set the system date to the 31st...
2
by: johnnypung | last post by:
Hello, I'm new to the forum and I definitely would hang around on here more in the future! I never knew the existence of this site! anyways, I have a question about windows, and wondering whether...
2
shek124
by: shek124 | last post by:
I want to run a windows startup program. here my code: Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long Public Declare Function RegCreateKey Lib...
3
by: PRR | last post by:
I have a console program.. which i need to convert to a windows service... My basic requirement is that the program needs to run in background and consume as less memory n CPU time as possible..I am...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
1
by: SilverGS | last post by:
I want to automatically open a Command Window from the Startup folder in Windows XP. right now after XP starts, I click on Start run, cmd and then when the command window is open I type in a bunch...
1
by: superstew | last post by:
Very basic info for beginners, by a beginner. IDLE is the learning console that comes with most Python distributions. I am new to playing with Python and wanted to get IDLE to load when I logged into...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.