Execute a command before Windows 7 loads?

By Mugsy ยท 15 replies
Apr 12, 2011
Post New Reply
  1. 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?
  2. Rick

    Rick TechSpot Staff Posts: 4,572   +65

    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...
  3. Mugsy

    Mugsy TS Guru Topic Starter Posts: 438   +31


    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.

    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.

    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).

    "Gigabyte"s only recommendation was to send them back my MoBo. Not really an option.

    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. :(
  4. Rick

    Rick TechSpot Staff Posts: 4,572   +65

    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?
  5. Mugsy

    Mugsy TS Guru Topic Starter Posts: 438   +31

    I just need to adjust the time/date prior to booting.

    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.

    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.
  6. jameslr

    jameslr TS Rookie

    If you're trying to delay scheduled tasks - stop the task scheduler service or disable it.
  7. Mugsy

    Mugsy TS Guru Topic Starter Posts: 438   +31

    Not an answer

    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.
  8. jameslr

    jameslr TS Rookie

    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.
  9. Mugsy

    Mugsy TS Guru Topic Starter Posts: 438   +31

    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.
  10. Mark56

    Mark56 TechSpot Paladin Posts: 1,886

    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.


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


    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).
  11. Mugsy

    Mugsy TS Guru Topic Starter Posts: 438   +31

    Notthe point.

    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.)
  12. hellokitty[hk]

    hellokitty[hk] Hello, nice to meet you! Posts: 3,448   +145

    There are many utilities that allow you to modify the startup order and timing of things in your startup.
  13. Mark56

    Mark56 TechSpot Paladin Posts: 1,886

    Considering the project you have in mind I would suggest you find a forum that may have some people who can help with some kind of Boot Loader, this site has some very knowledgable people who may be able to help.

  14. Mugsy

    Mugsy TS Guru Topic Starter Posts: 438   +31

    Not helpful.

    And if that was what I was trying to do, I could probably quit now.
  15. Mictlantecuhtli

    Mictlantecuhtli TS Evangelist Posts: 4,345   +11

    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).
  16. Mugsy

    Mugsy TS Guru Topic Starter Posts: 438   +31


    Finally something helpful. Thanks. I'll look into it and let you know what I get.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...