How to make DOS look even more like Unix

By Sandra Henry-Stocker, ITworld.com |  Operating Systems, DOS, Sandra Henry-Stocker Add a new comment

One of the other problems that I ran into when trying to make my DOS prompt behave more like my Unix systems was how to invoke my carefully crafted macros every time I opened a new DOS command window. When I put the commands to change my prompt and invoke my macros in a batch file and then ensured that this batch file was on my search path, I could reduce the effort that I had to make to running the batch file every time I opened a command prompt. I've since learned that it is possible to have my batch file invoked automatically whenever I open a DOS window (i.e., run cmd.exe). So, in this week's column, we're going to examine how this can be done.

To quickly review how I captured and then restored my macros in the first place, recall that I created my macros with the doskey command and then stored them in a text file by using the doskey /m command and redirecting the output to a file:

>doskey /m > C:\batfiles\macros.txt

I then created a batch file which both changed my prompt (setting it to "> " with the DOS command "prompt=$G$S") and activated my macros with the command "doskey /macrofile=C:\batfiles\macros.txt".

> type \batfiles\customize.bat
@echo off
:: set up macros and custom prompt

doskey /macrofile=C:\batfiles\macros.txt
prompt $G$S

To effect the changes in my prompt and available macros, I then had to run my batch file every time I opened a DOS command window. I would open a window and then type "customize" (NOTE: To run a batch file, you type its file name without the .bat file extension). So now, I want this all to happen without my having to remember to type "customize".

Before we get started, however, we first have to decide whether we want our macros to be invoked only for a particular individual or for everyone who uses the system. Most PCs are used solely or predominantly by a single individual. I dare say that this is why they are referred to as "personal" computers. But, if you're working on a shared system, you may want to make your system changes so that everyone can use them.

Setting up our system so that our macros are activated whenever the DOS window is opened requires a registry change. Don't be intimidated by that fact. If you're careful, a registry change will work as intended and have no unplanned side effects. However, caution is always in order when you edit the registry as many aspects of your Windows system depend on registry settings. In fact, many people with far better Windows skills than I will ever possess never edit their registry without first making a backup copy. Others back up only the keys that they plan to change. How to create a backup of your registry might be slightly different in different versions of Windows but, on my Windows XP Professional system, the operation requires only an export operation from the file menu.

Changing the Registry for Yourself

If you want your registry changes to only affect your own account, here's what you need to do:

First, open the registry with regedit (the name of this command may vary slightly between versions of Windows). You will note in the left panel that you have a series of headings and subheadings. Clicking on one of the + signs opens the menu of items below. Clicking on a - sign closes it. Next, navigate your way through the tree-like structure by sequentially selecting each of the items in this path:

HKEY_CURRENT_USER\Software\Microsoft\Command Processor

Once you get to the location indicated, you should see something that looks like this in the right-hand pane:

Default			REG_SZ		(value not set)
CompletionChar		REG_DWORD	0x00000009 (9)
DefaultColor		REG_DWORD	0x00000000 (0)
EnableExtensions	REG_DWORD	0x00000001 (1)

Next, select Edit->New->String Value from the menu choices. This will add an item to the list in the right pane. Overwrite the default name (New Value #1) by typing "AutoRun". If you make a mistake, you can right click and select Rename to type the name or Delete to remove the new item altogether and start over.

Then, select Edit->Modify to replace the (empty) value of the new string to the full path of your customize.bat file. Enclose the path in double quotes if there are spaces in your file name.

To exit your registry, select File->Exit. You don't have to separately save your changes. Your changes have already been made.

The next time you open a DOS window, your macros will be already in effect. When I open a DOS window, for example, I notice that my prompt is simply a > followed by a blank and that my macros are all available.

    Add a comment

    Post a comment using one of these accounts
    Or join now
    At least 6 characters

    Note: Comment will appear soon after you have activated your account.
    Obscene/spam comments will be removed and accounts suspended.
    The information you submit is subject to our Privacy Policy and Terms of Service.

    ITworld LIVE

    Operating SystemsWhite Papers & Webcasts

    White Paper

    Microsoft Enterprise Agreement Program Overview

    Discover how flexible the Microsoft Enterprise Agreement Program is to help you build the right software solution agreement for your business. This paper highlights all the available options-from on-premise software and cloud service solutions, to payment options and enrollment programs, and more.

    White Paper

    Watson - A System Designed for Answers. The future of workload optimized systems design

    Watson is a workload optimized system designed for complex analytics, made possible by integrating massively parallel POWER7 processors and DeepQA technology. Read the white paper about Watson's workload optimized system design.

    See more White Papers | Webcasts

    Ask a question

    Ask a Question