Click to See Complete Forum and Search --> : Making my application a startup program?
Ch0pinZee
February 2nd, 2005, 03:14 AM
I have just finished writing a program in Visual Basic.NET and would like for it to automatically make itself a startup program (one of the processes that starts automatically when Windows starts) during run time. Is there a way to program this right into the code itself, without having to make an installation file? For example, if I had a button on my form that said "Make me a starup program!", the user can click it and it would execute the necessary code to do this. What exactly would be the code for this button? Any help would be greatly appreciated!
Thanks,
Chopinzee
DSJ
February 2nd, 2005, 10:28 AM
Just put the EXE or a shortcut to it in the Startup folder.
Ch0pinZee
February 2nd, 2005, 11:21 AM
Yes but I don't want the end user to have to copy the program to the startup folder themselves, I want the program to do it automatically during run time.
usmanibnesadiq
February 3rd, 2005, 01:20 AM
hi why dont you put the code in a window service and make it start automatically as OS starts. i think its a better option. sorry i had the same idea to copy the exe in Startup folder. anyways
4461766964
February 3rd, 2005, 11:37 AM
Alternately you can manually create a new string value registry key in:
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\
I would caution that improperly adding an application as a startup item can have harsh and unexpected results. Edit the Windows registry at your own risk.
DS
Ch0pinZee
February 3rd, 2005, 01:24 PM
Alternately you can manually create a new string value registry key in:
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\
I would caution that improperly adding an application as a startup item can have harsh and unexpected results. Edit the Windows registry at your own risk.
DS
So how do you do this? Like what would the code be for example?
Ch0pinZee
February 7th, 2005, 01:38 AM
Surely someone must know...
Boumxyz2
February 7th, 2005, 12:27 PM
I don't have much time to show you but check that namespace in .NEt
microsoft.Win32
should help you out with the registry.
1FstZed
February 15th, 2005, 09:25 PM
I know in C# the code is as folows
include this using statement using Microsoft.Win32;
create a registry key object
RegistryKey rootkey,pKey,sKey;
then the fun begins the following line is how to open a connection
rootkey = Registry.LocalMachine.OpenSubKey("Software", true) this can be any key
once the initial connection is made you have to make the keys in the registry to store you're data
pKey = rootkey.CreateSubKey("KeyName"); this creates a key under Software
sKey = pKey.CreateSubKey("KeyName"); this creates a key under the one created with pKey;
now to set values use the sKey object to create them
sKey.CreateKey("Key Name", (string)Keyvalue);
sKey.CreateKey("Key Name", (int)Keyvalue);
and so on then use
sKey.Close();
pKey.Close();
rootkey.Close();
this is what i have done if any further help is needed email me at jscheibe@cogeco.ca
Josh
Dorez
February 18th, 2005, 02:20 PM
If you don't want to copy the exe to the startup folder, you could create a shortcut to the exe in the startup folder.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.