Run your application on Startup

Use this board to post your code snippets - tips and tricks
18 posts Page 1 of 2
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4390
Joined: Tue Aug 04, 2009 1:47 am

Run your application on Startup
CodenStuff
Hello,

This maybe useful to some of you just incase you want to run your application when the system boots up.

It adds/removes and entry from the registry so please be careful.

To add your application to startup:
Code: Select all
Dim AddToStartup As Microsoft.Win32.RegistryKey
AddToStartup = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
AddToStartup.SetValue("Jimbob", Application.ExecutablePath)
AddToStartup.Close()
To remove your application from startup:
Code: Select all
Dim AddToStartup As Microsoft.Win32.RegistryKey
AddToStartup = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
AddToStartup.DeleteValue("Jimbob")
AddToStartup.Close()
In both codes you will see the word "Jimbob", replace this word with a unique identifier for your application. It can be anything you like its just a name for your application. Make sure you use the same identifier when adding/removing from the registry.

I dont know why I use the word Jimbob alot lol, I must have watched too many episodes of the Waltons when I was growing up :lol:

Happy coding cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
MasterCoding
Top Poster
Top Poster
Posts: 156
Joined: Sat Oct 24, 2009 4:26 pm

works this with 64x bit because i wanna make a program for a friend and he has 64x bit
User avatar
AleRi8
Top Poster
Top Poster
Posts: 153
Joined: Sun Sep 20, 2009 2:30 pm

Re: Run your application on Startup
AleRi8
i dont see why it shouldn't work
check out my software
win7 itweaker basic £4.50
viewtopic.php?f=70&t=793
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Run your application on Startup
Lewis
Thanks for this! ims hure it will come in handy :D
Image
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Nice little tip codenstuff, I will have to try this out :)

Many Thanks

Chris
Image
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

thanks
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Couldn't you modify this to copy the program to the Startup folder and it would be easier? I'm not sure but could you?
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

I was looking for something like this, but is it, cause of the registry that makes it startup when logged in, or what???
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

think its for current uer
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Nice Tutorial Codenstuff.
I have used this very same code as an option in many of my projects.
It works very well, And I have found to be safe to use.

Because I use SpyBot to protect all my registry information, SpyBot
or other registry watcher software will be alerted on any chance made to the registry.
(This is a good thing)

I have tested it on XP sp1,2 and 3 Vista(All Versions) and I have had no problems using this code.

Scottie1972
Image
18 posts Page 1 of 2
Return to “Quick Snips”