I'm looking for a way of running a batch script once (and only once) on boot before the Windows XP Logon prompt appears on screen.

What is the easiest way to do this?

Also, I need to be able to run this command before the network has started (or if the network has failed to start).

2 Answers 2


Use a computer start up script.

You can do this using either local policy editor (standalone PC or on a domain) or group policy editor (on a domain only.)

Navigate to this settings via

Computer Settings > Windows Settings > Scripts > Startup

The script will run as the local system account

  • Will this work if the PC doesn't have network access?
    – orj
    Aug 24, 2009 at 23:50
  • @orj...Yes 15char Aug 24, 2009 at 23:53
  • My answer no longer fits the edited version of the question, however Sam's idea of setting a flag below will do this. I'd do this by touching a file e.g. 'echo Done > %windir%\scriptrun.orj', then check it using 'if exist %windir%\scriptrun.orj then exit'. However a computer startup script will only run after the network has started.
    – Bryan
    Aug 25, 2009 at 12:40

If you only want the script to run once, then you will need to manually set flag at the completion of the script and check it at the start (otherwise the script will run every time you start the computer until you take it out of the policy).

The easiest way is to either create an empty text file in a known location and check for its presence. Alternativly you can use the 'reg query' and 'reg add' commands in the batch file to set the flag in the registry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.