| 225 |
| Run commands automatically when a console opens |
| Windows provides a handful of means to control the way console sessions start and function. For |
| example, you can click a console's Control menu, select Properties, and configure properties such |
| as cursor size, display options, font, and layout. |
| Besides configuring properties, you might also want to execute commands automatically when you |
| open a console. For example, you might want to load a device driver, switch to a particular directory, |
| set the command prompt, or execute a batch file. |
| Adding a command string to the registry is one simple solution. Open the Registry Editor to the |
| following key and enter a command string as its value: |
| HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun |
| Cmd.exe executes this command string at startup for all command console sessions. |
| You can include a command string for a specific console session by starting the session with the /K |
| switch. For example, the following example would start a console session and change to the |
| \Documents and Settings folder: |
| Cmd.exe /K "CD \Documents and Settings" |
| Note: Editing the registry is risky. Before making any changes, back up the registry so you can |
| restore it if something goes wrong. |
First Previous Next Last |