Automatically Create a Folder-Specific Console Session

Use InitHere to automatically apply command-line customizations.

Alex Angelopoulos

November 24, 2002

1 Min Read
ITPro Today logo

When you use command-line tools, you must customize certain environmental elements every time you open a new command prompt. You'll often be working in the same directory each time you need to apply a particular set of customizations, so having an automatic method for applying customizations would be handy. The registry tweak InitHere is a simple modification of the CMD Prompt Here PowerToy that lets you easily make such changes automatically.

To install the InitHere PowerToy, right-click InitHere.inf, which Listing 1 shows, and select Install from the context menu. After you install the PowerToy, you'll have a new context menu choice for InitHere when you select a folder. Selecting InitHere automatically opens a command prompt in the folder. InitHere also looks for a file named init.cmd in the folder; if the file exists, the commands in the file will execute immediately. To illustrate some of InitHere's conveniences, the example INIT.cmd script in Listing 2 sets the console's color, customizes the screen, temporarily adds a directory to the path, echoes some potentially important reminder information for the session, then switches to another working directory.

If you simply want to run a script every time you open a command prompt, you can use an even easier method. The HKEY_LOCAL_MACHINESOFTWAREMicrosoftCommand Processor and HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor registry subkeys support an AutoRun REG_SZ value into which you can insert the full path to the script or executable you want to run when the console session starts.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like