Programming4us
         
 
 
Windows

Windows 7 : Working at the Command Line (part 2)

12/5/2010 11:46:32 AM

Taking Advantage of DOSKEY

Windows 7 loads the DOSKEY utility by default when you start any command-line session. This useful little program brings a number of advantages to your command-line work:

  • You can recall previously entered commands with just a keystroke or two.

  • You can enter multiple commands on a single line.

  • You can edit commands instead of retyping them.

The next few sections take you through the specifics.

Recalling Command Lines

The simplest DOSKEY feature is command recall. DOSKEY maintains a command history buffer that keeps a list of the commands you enter. To scroll through your previously entered commands in reverse order, press the up-arrow key; when you’ve done that at least once, you can change direction and run through the commands in the order you entered them by pressing the down-arrow key. To rerun a command, use the arrow keys to find it and then press Enter.

Tip

If you don’t want to enter commands from the history buffer, press Esc to get a clean command line.


Table 2 lists all the command-recall keys you can use.

Table 2. DOSKEY Command-Recall Keys
PressTo
Up arrowRecall the previous command in the buffer.
Down arrowRecall the newest command in the buffer.
Page UpRecall the oldest command in the buffer.
Page DownRecall the newest command in the buffer.
F7Display the entire command buffer.
Alt+F7Delete all commands from the buffer.
F8Have DOSKEY recall a command that begins with the letter or letters you’ve typed on the command line.
F9Have DOSKEY prompt you for a command list number. (You can see the numbers with the F7 key.) Type the number and press Enter to recall the command.

Tip

The command history buffer holds 50 commands by default. If you need a larger buffer, run DOSKEY with the /LISTSIZE=buffers switch, where buffers is the number of commands you want to store. You also need to include the /REINSTALL switch to install a new copy of DOSKEY, which puts the new history buffer setting into effect. For example, to change the buffer size to 100, enter the following command:

doskey /listize=100 /reinstall


Entering Multiple Commands on a Single Line

DOSKEY enables you to run multiple commands on a single line. To do this, insert the characters && between commands. For example, a common task is to change to a different drive and then run a directory listing. Normally, you’d do this with two separate commands:

e:
dir

With DOSKEY, however, you can do it on one line, like so:

e:&&dir

Tip

You can enter as many commands as you like on a single line, but just remember that the total length of the line can’t be more than 8,191 characters (which should be plenty!).


Editing Command Lines

Instead of simply rerunning a previously typed command, you might need to run the command again with slightly different switches or parameters. Rather than retyping the whole thing, DOSKEY enables you to edit any recalled command line. You use various keys to move the cursor to the offending letters and replace them. Table 3 summarizes DOSKEY’s command-line editing keys.

Table 3. DOSKEY Command-Line Editing Keys
PressTo
Left arrowMove the cursor one character to the left.
Right arrowMove the cursor one character to the right.
Ctrl+left arrowMove the cursor one word to the left.
Ctrl+right arrowMove the cursor one word to the right.
HomeMove the cursor to the beginning of the line.
EndMove the cursor to the end of the line.
DeleteDelete the character over the cursor.
BackspaceDelete the character to the left of the cursor.
Ctrl+HomeDelete from the cursor to the beginning of the line.
Ctrl+EndDelete from the cursor to the end of the line.
InsertToggle DOSKEY between Insert mode (your typing is inserted between existing letters on the command line) and Overstrike mode (your typing replaces existing letters on the command line).

Other -----------------
- Windows 7 : Getting to the Command Line (part 2) - Running CMD
- Windows 7 : Getting to the Command Line (part 1)
- Windows Azure : Programming Access Control Service (part 10) - Deploying the Web Service in Windows Azure
- Windows Azure : Programming Access Control Service (part 9) - Configuring a Web Service Client to Acquire and Send SAML Tokens
- Windows Azure : Programming Access Control Service (part 8)
- Windows Azure : Programming Access Control Service (part 7) - Integrating ACS with a SAML Token Provider
- Windows Azure : Programming Access Control Service (part 6)
- Windows Azure : Programming Access Control Service (part 5)
- Windows Azure : Programming Access Control Service (part 4)
- Windows Azure : Programming Access Control Service (part 3)
- Windows Azure : Programming Access Control Service (part 2)
- Windows Azure : Programming Access Control Service (part 1)
- Windows 7 : Working with Registry Entries (part 3)
- Windows 7 : Working with Registry Entries (part 2)
- Windows 7 : Working with Registry Entries (part 1) - Changing the Value of a Registry Entry
- Windows 7 : Keeping the Registry Safe
- Windows 7 : Getting to Know the Registry (part 2)
- Windows 7 : Getting to Know the Registry (part 1) - Understanding Registry Settings
- Windows 7 : Firing Up the Registry Editor
- Windows Azure : Managing Access Control Service Resources (part 2)
 
 
Most View
- Programming Excel with VBA and .NET : Procedures - Properties & Events
- Configuring a Microsoft Exchange Server 2003 Infrastructure : Post-Installation Considerations
- Navigating the Central Administration Home Page (part 2)
- Developing for Windows Phone and Xbox Live : 3D Math Basics (part 2) - Vectors in 3D graphics
- Windows Server 2008: Understanding and Deploying BranchCache (part 3)
- BizTalk Server 2010 : WCF SAP Adapter RFCs and BAPIs - Overview of SAP RFCs and BAPIs
- Exchange Server 2003 : Configuring Interoperability with Other SMTP Messaging Systems
- iPad SDK : New Graphics Functionality - The Basic Drawing Architecture
- Windows Phone 7 Game Development : The World of 3D Graphics - The Depth Buffer
- Exchange Server 2010 Mailbox Services Configuration (part 1)
Top 10
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 3) - Configuring Recipient Filtering
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 2)
- Implementing Edge Services for an Exchange Server 2007 Environment : Utilizing the Basic Sender and Recipient Connection Filters (part 1)
- Implementing Edge Services for an Exchange Server 2007 Environment : Installing and Configuring the Edge Transport Server Components
- What's New in SharePoint 2013 (part 7) - BCS
- What's New in SharePoint 2013 (part 6) - SEARCH
- What's New in SharePoint 2013 (part 6) - WEB CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 5) - ENTERPRISE CONTENT MANAGEMENT
- What's New in SharePoint 2013 (part 4) - WORKFLOWS
- What's New in SharePoint 2013 (part 3) - REMOTE EVENTS