Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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

share|improve this answer
Will this work if the PC doesn't have network access? – orj Aug 24 '09 at 23:50
@orj...Yes 15char – prestomation Aug 24 '09 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 '09 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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