Enterprise Software

Automatically run a batch file when you open a Windows XP command prompt

You probably run the same few commands each time you start using the command prompt in Windows XP. You can save yourself from typing any commands at all if you add the path and name of the batch file to a special key in the registry. Here's how to add them.

You probably run the same few commands each time you start using the command prompt in Windows XP. For example, perhaps you first switch to the root directory and then clear the screen. Then, you may have put these commands into a batch file and saved the file to the C:\Documents and Settings\{username} folder so that when you open the command prompt, you simply type the name of the batch file to issue the commands.

You can save yourself from typing any commands at all if you add the path and name of the batch file to a special key in the registry. Here's how to add them:

1. Launch the Registry Editor (Regedit.exe).

2. Go to theĀ  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor key.

3. Double-click the AutoRun value to access the Edit String dialog box.

4. In the Value Data text box, type the path and name of the batch file. Be sure to enclose the text in double quotes — for example, "C:\Documents and Settings\greg\go.bat".

5. Click OK to close the Edit String dialog box and close the Registry Editor.

Now, your batch file will automatically run every time you open the command prompt window.

Caution: Editing the registry is risky, so make sure you have a verified backup before making any changes. Note: This tip is for both Windows XP Home and Professional.

Miss a tip?

Check out the Windows XP archive, and get more hands-on Windows XP tips.

Stay on top of the latest XP tips and tricks with our free Windows XP newsletter, delivered each Thursday. Automatically sign up today!

About

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

Editor's Picks