I don't know really anything about C++. I'm just making some super-easy-to-write programs and I was thinking while I'm learning more, some of the programs I make I might want to be put in the startup folder so they run at startup. I know there's some way to either write an .exe to a folder or make an .exe copy itself to a folder.
Help!
If you give me source code please put something like //PUT YOUR CODE IN HERE so I know where my already-built code goes(again, I don't know anything :()
The "Startup" Folder is literally a folder in a user profile, treat it like any other directory. In order for you to get your application to start for everyone that logs on you want to drop it in "All Users". If you only want it to apply to newley created users and not anyone who has an established profile then drop it under "Default User".
Example:
Windows XP: C:\Documents and Settings\All Users\Startup
Windows Vista & 7: C:\Users\All Users\Startup
In order to get you application to startup with the special "Service Accounts" you need to target them specifically. They are LocalSystem, LocalService and NetworkService. In Windows XP they are in the Document and Settings directory just like any other profile. But in Windows Vista and 7 they are:
To explain why there are three different service profiles is beyond the scope of this post, please consult MSDN for information in this regard.
NOTE: The only reason I'm entertaining this question is because this is more useful for a practical joke then it is for kind of malicious intent and it does not pose any real threat to end users. Therefore this serves as an informational post about the structure of the Windows environment not a 'How to pwn Puters' handbook.
Right because the only legitimate use for running a program at startup is a virus. Fuck, why don't we just delete the startup folder and registry entries, not like anything needs to ever be run at startup!
Thanks for being completely useless bro!
The startup folder should have shortcuts not .exe files. It is probably not a good idea to have your program create them either.
If you really don't know much about C++ at the moment, this is not the sort of thing you want to be stressing about. If you want your program to run on startup manually create the shortcut and move on.
I'm actually glad you said this. YES I believe that there is NO LEGITAMITE REASON FOR AN APPLICATION TO EXECUTE ON STARTUP.
My printer\scanner, IM client, VPN, Search indexer, On-Line Cheating Detector and a thousand other applications DO NOT NEED TO START JUST BECAUSE I LOG IN. But because of mislead programmers like yourself who are taught that the end user needs to be bottle fed their PC startup settings I need to delete 4 or 5 entries for every 1 application that I install. If you are writing an Anitvirus client then you should have the brains to modify a bootloader, maybe then you would be able to detect a f***ing rootkit. The same for system administrators.
So, I'll play along OP. Enlighten us as to what application should be executed everytime a user logs in?
Even though Computergeek01 was far too harsh in his post and I would like to shake my head solemnly at the seeming anger, I agree with the general idea.
One reason I left the Windows platform was because of the irritation of having to clear out entries that get programs to load at startup to avoid horrendous loading times. Most of those applications didn't even have a slightest reason to start, aside from weighing down the entire platform by consuming resources I needed. :)
@ Albatross: Punk Buster. and yeah I was too harsh on the OP. It's something that bothers me when people assume that thier program is somehow special. If I want it then I'll start it myself. Sorry about the anger issue.
I don't think it's special. I never said it was. It's just 1000x easier to have something start on startup if you're going to use it right away every time than to go to the start menu or the folder it's in and open it.
There are SO many more options with the Win32 API though. Like I said if it is a security program then modifying the boot loader is the closest you can get to being bullet proof. If it's something like a VNC host then it needs to be started as a service when the system boots and before the user logs in.
Starting with the user profile not only slows the user down, and in an office environment you could cost someone their job for punching in late BTW, but it's asychronise things just execute whenever they can. Things like antivirus conflict with things like Windows(NT) Roaming profiles. One wants to load the user settings, the other wants to scan EVERY file that is being processed and all of this occurs BEFORE explorer executes. The end user sees a lock up at the station but it will NEVER time out or take anyother action because technically there is no problem with the connection. Then when one wants to process a file that the other has an exclusive lock on all hell breaks loose. This is all because of the same mindset that has seems to have been ingrained in you.
Wowo, I agree there are very few reasons for a startup program and zero reasons for a programmatic solution... however I keep track of my day with a custom screencap and keylogger, it's gotten me out of a lot of jams and if for some reason a less than technical idiot steals my compie, I have my logs sent to a server periodically so I can peruse them at my leisure =) I'm pretty sure he'd like to give it back with the social pressures of hacked accounts and perhaps banking info if he's less than intelligent =D
On the other hand, my program could easily be used maliciously... I see that which is why I'm the only one who has ever seen my full source or used my full program for that matter. IDK it's kinda useful in that regard.
^ That's an amazing idea. Should leave a laptop running with stuff that looks really important/valuable in a starfucks and wait for someone to steal it while you're in the bathroom then screw them and steal their email password and crap.