Add and remove program's in the "startup menu"

Feb 8, 2013 at 7:59pm
When windows logs in it starts so many program's that are crucial but also so many extra program's that the user installs such as Skype, you have an option to start Skype on login. Anything that starts on login is in a menu under system configuration (search in start menu) in a tab called startup... How do I as my program to this menu and automatically enable?
Feb 9, 2013 at 12:40pm
Add the path to your program in the registry:

HKCU\Software\Microsoft\Windows\CurrentVersion\Run
Feb 9, 2013 at 6:34pm
How would I code in C++ (or C or DOS) how to automatically add it into that directory?
Feb 9, 2013 at 8:36pm
Use the registry API. All I know off the top of my head is you need to open the key, add the value, and then close the key. The function names should be obvious if you look at the reference page:

http://msdn.microsoft.com/en-us/library/ms724875(v=vs.85).aspx
Feb 9, 2013 at 8:46pm
You may also be able to add it directly to the Start Menu using
the shgetknownfolderpath function to get the Start Menu folder and adding it directly to the StartUP folder.
Feb 9, 2013 at 9:11pm
Thanks, the MSDN looks like it could have some good stuff (don't know why I didn't think of that)
Now just to figure out what functions to use and how the hell to string them together!?
Feb 9, 2013 at 9:40pm
Right I think I need to create a new directory for my program and then what-ever data it needs to link to the program in this registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
Don't suppose someone could double check that to make sure it's safe to edit this and add my own program in there?

And I think I start doing this by using:
1
2
3
4
5
6
7
RegOpenKeyEx(
        HKEY_CURRENT_USER,
        "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
        0,
        KEY_WRITE,
        //I don't know how to setup this final argument, tbh I don't know what a handle is.
);

http://msdn.microsoft.com/en-us/library/ms724837(v=vs.85).aspx
Looking at other programs such as daemon tools or skype I need to add a string variable with my program path but there are certain arguments that need to come after this such as in skype it shows "/minimised /regrun" and in daemon tools it shows "-autorun"
Last edited on Feb 9, 2013 at 10:08pm
Feb 10, 2013 at 6:57am
1
2
3
4
5
6
7
8
9
10
11
12
13
HKEY hKey;
RegOpenKeyExA(
        HKEY_CURRENT_USER,
        "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
        0,
        KEY_WRITE,
        &hKey
);

char [] myapp = "C:\\myapp.exe";
RegSetValueExA (hKey, "MyAppName", 0, REG_SZ, myapp, sizeof (myapp));
RegCloseKey (hKey);
Last edited on Feb 10, 2013 at 6:58am
Feb 10, 2013 at 12:11pm
That additional stuff for skype and daemon tools are command line parameters. "/minimize" and "-autorun" probably tell the respective programs to run in the background.
Feb 10, 2013 at 1:52pm
@AHCFan20
So when the system runs the programs in the "Run" key it's like opening the programs through cmd and typing "/minimize" after the program, to send it to main(sting arg[])?

@modoran
Thanks for the info, just checked what the arguments on RegSetValueEx(//args) do, Most of it seems to make sense to me... Cheers XD
Feb 11, 2013 at 12:11pm
So when the system runs the programs in the "Run" key it's like opening the programs through cmd and typing "/minimize" after the program, to send it to main(sting arg[])?


That's right. Every process has a command line regardless of how it is executed.
Feb 11, 2013 at 9:22pm
This is pretty much solved then (I'll just lookup how to remove which I'm fairly certain should be quite similar)...
But since it's linked in, does anybody know the name of the directory or registry which is used for windows program list? (i.e. The big list of programs under the "edit or remove programs" from windows control panel)
Feb 12, 2013 at 4:08am
The registry key you seek is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

However, you should use a dedicated installer like NSIS or InnoSetup instead of manually doing it.
Feb 14, 2013 at 10:42pm
Thank you very much!
And my intention is to make an installer using the directories.
Topic archived. No new replies allowed.