Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

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

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
add comment

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
add comment

Your Answer

 
discard

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.