Windows – Adding a different program to startup


How would I add a completely different program on the computer to start up?
Would it be something like this?

My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, "C:\APPLICATIONSPATH.fileextension")

P.S: Sorry for being a noob.

Best Answer

There are several ways to add a startup program.

Firstly what OS are you using? By the looks of it a version of Windows?

And what programming language are you wanting to use? C Sharp?

Assuming you have privileges to write to the registry then what you have written looks mostly correct. Have you tried testing it? There is also a RunOnce subkey to allow the program to only run on the next occasion of startup. I have actually done what you are trying to do before, however I am on a computer with limited privileges at the moment so I can't check that what you have written is perfectly correct. Although the idea should be fine :)

You may also like to write a shortcut to the Windows Start menu "Startup" folder. You could write a short piece of code to create a shortcut file to the application you wish to run and then attempt to write the shortcut file to the correct startup directory? If not a shortcut file, write a script file which is much easier. Perhaps something like:

@echo off
echo Running a startup program!
::load program
start /b "" "C:\APPLICATIONSPATH.fileextension"

and programmatically write this to a file with a .vbs extension. This way if a user who is not computer savvy wants to remove the startup item manually they can easily see it. (I think this may be a way which will work without the requirement for administrative rights. Could be a useful alternative to writing to the registry?)

If you use Windows 8, this startup folder no longer exists under the start menu. Instead it can be found here: C:\Users\YOURUSER\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

or with the Windows Run prompt: Win+R and by running shell:startup

enter image description here

Have a look here for Windows 8

Related Question