12/31/2004

Tip: Run commands automatically when a console opens

Filed under: Aviran Mordo @ 10:22 pm

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”

 

Leave a Reply

You must have Javascript enabled in order to submit comments.

All fields are optional (except comment).
Some comments may be held for moderation (depends on spam filter) and not show up immediately.
Links will automatically get rel="nofollow" attribute to deter spammers.

Powered by WordPress