Execute a command before Windows 7 loads?

Mugsy

Posts: 772   +203
I want to execute a simple "DOS" command BEFORE Windows 7 starts.

Of course, I don't need DOS specifically (I know Windows hasn't preloaded "DOS" before the GUI since "Windows ME"). I just want to load/run tiny DOS-like commands before Windows starts.

I know in XP, programs like "HiJack This" could tell Windows to delete suspicious files before the OS loads. Can the same thing be done in Win7?

My clock is losing time (even after a battery replacement), and I'd like to be able to add 30 seconds (or more) to the clock prior to boot. I think a simple EXE, or even a DOS "Time" command in a ".bat" file during startup would help immensely (I tried adding an "Autoexec.bat", but W7 ignored it.)

Is what I'm asking even possible?
 
If you lose 30 seconds ever X number of hours, are you planning on restarting your computer every X number of hours? How would you be able to keep your time accurate this way unless you restart your computer every X number of hours?

Also, why fix it before Windows is loaded.. What's the importance of that? Why not after? Windows CAN change the time if that's what you want. You could do something like make a batch file that runs: w32tm /resync once you log in. Just drag it into your startup folder or have it scheduled with task manager etc.. You'll need to have the Windows Time service enabled though. Start > Run > services.msc and make sure "Windows Time" is set to automatically start.

I'd also be wondering why this is happening. I honestly don't have a suggestion for you since the only issues I've seen like this were always the CMOS battery. Hmmm...

As far as I know, you won't be able to load anything BEFORE Windows loads without some special boot loader and preboot environment. As far as DURING boot, it may be possible. The next best thing would be to run a script as the system user using a group policy (Start > Run > gpedit.msc and browse to Computer Configuration > Windows Settings > Scripts [Start/Shutdown]). The Windows Time service won't be available during this point though, so you could load your "+30 secs script here, but I'm unsure how you would do that with a batch file, VBS script etc...
 
Pre-command

If you lose 30 seconds ever X number of hours, are you planning on restarting your computer every X number of hours? How would you be able to keep your time accurate this way unless you restart your computer every X number of hours?
I do not leave my PC on 24/7. I power down every night. But the time loss is not consistent. Sometimes I seem to lose more than a minute in just a few hours. Other days I don't seem to lose any time at all.

Also, why fix it before Windows is loaded.. What's the importance of that? Why not after?
Because I have startup apps (like the TV) that I need to launch on schedule. Setting each and every recording to start a minute early is annoying, creates conflicts with other loading apps, and misnames my recordings.

There are other advantages to adding an extra delay of a few minutes (to even a few days) temporarily when it comes to startup apps.

Windows CAN change the time if that's what you want. You could do something like make a batch file that runs: w32tm /resync once you log in. Just drag it into your startup folder or have it scheduled with task manager etc..
As I noted, I need to adjust the time BEFORE anything loads. Using the Task Scheduler is too late, loading only after many startup apps have loaded (and no control over the order).

I'd also be wondering why this is happening. I honestly don't have a suggestion for you since the only issues I've seen like this were always the CMOS battery. Hmmm...
"Gigabyte"s only recommendation was to send them back my MoBo. Not really an option.

As far as I know, you won't be able to load anything BEFORE Windows loads without some special boot loader and preboot environment.
Even without the issue of my clock not keeping good time (when it happened in XP, I suspected I had too many Tray apps running, but even after disabling everything, the problem persisted), I'd still want to do this (most notably to cure my recording woes.)

Controlling the time of when a group of startup programs launches has usefulness beyond my clock issues.

I considered writing an EXE using my old copy of "C++ for DOS" to do this, but I couldn't figure out how to get it to execute before Windows loads. :(
 
Hmmm. This is probably just my own failure, but I just don't get what you're trying to do?

If the loss of time is inconsistent, then I'm not sure how adjusting the time by 30 seconds during reboot would help you very much? This is part of my difficulty understanding your request.

However, I think I understand why your clock needs to be updated *before* your TV software launches though. What if you could ensure that happens during logon? The process would be like this...

First, we would disable the mechanism that starts your TV software (Probably in Start > Run > msconfig.exe ). Then we could write a batch file which would launch something like w32tm /resync and *then* it would launch your TV software... sequentially. Then lastly, you could add that as a startup item by putting it in your startup folder (or other methods). Ultimately, this would sync your clock with a time server and once it is completed, load your TV software.

I know this isn't what you asked for originally, but do you think this could help you achieve your goal?
 
Hmmm. This is probably just my own failure, but I just don't get what you're trying to do?
I just need to adjust the time/date prior to booting.

If the loss of time is inconsistent, then I'm not sure how adjusting the time by 30 seconds during reboot would help you very much? This is part of my difficulty understanding your request.
The "time loss" issue is only a side issue. It's not my primary reason for needing to do this. But if it helps, when the clock looses time, it is usually no more than a minute. Sometimes it's zero. Split the difference: 30 seconds. Eventually the RTC will fix it.

But primarily, I'm trying to delay some scheduled tasks from trying to launch at the same time my startup apps are loading.

However, I think I understand why your clock needs to be updated *before* your TV software launches though. What if you could ensure that happens during logon? The process would be like this...

First, we would disable the mechanism that starts your TV software (Probably in Start > Run > msconfig.exe ). Then we could write a batch file which would launch something like w32tm /resync and *then*...
By this point, your recording has started too late. But TV isn't the only program I wish to delay the launch of (other uses: delaying certain apps from loading until after my Internet Connection is established.)

Sorry to be so vague, but I'm trying to develop a utility without revealing all it's features, including things I haven't even thought of yet. the list of things you could use this for is extensive.
 
Not an answer

If you're trying to delay scheduled tasks - stop the task scheduler service or disable it.
Two problems there:

1) I don't want to disable scheduled tasks, just delay them.

2) It's not just "scheduled tasks" I wish to delay, but anything that autoruns at startup (and hopefully add the ability to pick & choose what gets delayed so I can control the boot order.)

So far, I've been getting a lot of advice on how "I personally" can circumvent doing what I want/need. I'm writing a software program that might be of use to others. Simply telling everyone to "disable all their startup programs" and later launch each one individually by hand, is neither practical nor helpful.
 
1) You can re-enable the task scheduler. It's a simple dos command to do so.

2) See #1.

Your problem in essence seems impractical. You're struggling with a hardware clock problem and requesting a software based solution to it. Fix your hardware problem first.
 
1) You can re-enable the task scheduler. It's a simple dos command to do so.

2) See #1.

Your problem in essence seems impractical. You're struggling with a hardware clock problem and requesting a software based solution to it. Fix your hardware problem first.
As I said, I'm developing software. Resolving my personal clock issues is only a potential side benefit.

Your "solution" above is neither practical nor helpful. If you can not assist me, please do not clog up this thread with pointless "solutions" that don't address my needs.
 
I would like to suggest something that will keep your clock correct.

Right click on the time and date display in the bottom task bar and select Adjust Date/Time, click on the Internet Time tab and then Change Settings. Check the box to "Synchronize with an internet time server" and select one from the list. This should keep your time up to date.

Have you actually tested the voltage on the CMOS battery, if it is much below 2.5V it should be replaced, the correct voltage is 3V.

This software will delay start up programs.

http://www.winpatrol.com/

And so will this but I am not certain it is compatible with windows 7.

http://fileforum.betanews.com/detail/Startup_Delayer/1088376249/1

Other than that type services.msc into the search box and select Services in the pop up menu. Select any service>right click>properties and you can set the startup to automatic(delay).
 
Notthe point.

I would like to suggest something that will keep your clock correct.

Again, thank you to people offering to help me with any intermittent issues I am personally having with my clock, but I only mentioned it as one possible use for the program I am trying to write.

I need information on setting the clock prior to Windows loading. Any other information about my own clock is a mere distraction right now.

(And for those who may be wondering, I set my clock to update online every 24 hours. I have replaced the battery twice.)
 
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute does that, however, the applications have to be "native" NT ones, not using Win32 API (as that hasn't loaded at that point yet).
 
Good

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute does that, however, the applications have to be "native" NT ones, not using Win32 API (as that hasn't loaded at that point yet).
Finally something helpful. Thanks. I'll look into it and let you know what I get.
 
Back