I'm writing a program that I'd like to have started every time that Windows powers up.
I tried putting it as the last thing in autoexec.bat... no luck.
I added it to the Windows control panel/scheduled tasks thing, and it sure looks like I've set it up to run at startup. But it doesn't.
The program is a console-mode utility that I'm using just to test the startup mechanism. It should pop a window open on my desktop, or at least appear in the tray.
There's something broken on this laptop I got for $5 at a yard sale; it runs XP Home SP1 and can't update; the necessary ActiveX controls will not run no matter what I do.
OTOH it boots faster than any other machine in the house, and is fine for general browsing, email, and usenet, so I'm in no hurry to fix it.
Startup is the easiest way. You can put a shortcut to a batch file there. It will start up with the owner as the user who logs on.
To have the system own it, and have it start up always, you can add it into the registry (also makes it more invisible). Should be a matter of creating a text file ending in .reg and then merging it with a right click or double click.
Probably easiest to export an existing key, edit it, then enter it back in.
HKLM/Software/Microsoft/Windows/Current Version/Run has about 15 keys in one computer here with things like iTunesHelper, the firewall, and the Analog Devices sound controller(s).
Here is a valid .reg file (the parts between the --):
--
Replace the name with whatever you like and point the path to your
program and any parameters and I think it will work. Use \" as the
escape sequence for embedding " and \\ to embed \.
Be careful with registry modifications, apparently some people manage
to screw up their computers royally, though I've done hundreds of
changes with worst case effect that some piece of software has to be
re-installed.
There's a similar setting under HKEY_CURRENT_USER.
Also, both have RUN_ONCE, if that's what you need to do.
Best regards,
Spehro Pefhany
One thing to bear in mind with modern (NT-based) Windows which didn't apply to older (DOS-based) versions: the distinction between startup and login.
When the machine boots, no-one is logged in. You can run services in this state, but there's no desktop or current user, so anything which assumes that there is won't work.
You can configure programs to run when a user logs in (either a specific user or any user) via registry keys, e.g.:
However, some relatively important desktop services are also run via these keys, and there's no guarantee that they will have started before any custom programs are run.
Anything in the Startup folder gets started later (once Explorer is up and running), which tends to make it the easiest option if you just want an application to be started whenever you log in.
Either way, one pitfall is that XP and later allow multiple users to be logged in, so you can end up with multiple instances of the program on different desktops, which can confuse programs which weren't written with this in mind.
My Windows XP registry book tells you exactly where in the registry to do this. There are a number of options, all of which will probably have what you want.
ISBN-13: 978-0782129878
You can probably find a copy at any better library. Or a used book store.
Bummer. This is my cabin automation machine. I want this PC to start up after any power fail and run the automation app. I'd also like guests to be able to run under the "guest" login, not as me/admin.
Windows is garbage. I may have to get an entirely separate pc, maybe a small mini-ITX thing, to run this.
On a sunny day (Fri, 25 Dec 2009 08:48:27 -0800) it happened John Larkin wrote in :
John, you will also need a hardware watchdog. Even if the OS (whatever type) starts up correctly, it is my experience that sometimes BIOSes do not. That means the PC will stay off after a mains glitch, even if you specify in BIOS that it should restart. Your program should periodically write to some I/O, say a par port or serial port, the hardware should monitor that, and do a mains power sequence if the 'pulse' is not detected. It should also have a max count for the number of restarts, and phone you when that count is reached without a correct restart. I have done a system like that in the eighties, much to my amazement I came in some place some year ago and it was still in full operation there! IIRC I used shift registers for the counter in that time... no micro..
Checked: this doesn't start my app until a user logs in, and it starts it for all users. That won't work for what I want to do, so I suppose I'll have to hack the registry.
If you remove the password and have only one user set up, won't it log on automatically?
Best regards, Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
speff@interlog.com Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.