IT tutorials
 
Windows
 

Windows Server 2008 : Launching and Using the Command Prompt (part 2) - Using the Built-in doskey Program, Creating Mini Macros with doskey

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
4/9/2013 9:21:50 PM

3. Using the Built-in doskey Program

doskey is built in to the command prompt and keeps a history of all the commands you enter in the current command prompt session. You can easily retrieve previous commands so that you don’t have to type them again. For example, suppose you’re trying to export a DNS zone with the dnscmd /zoneexport pearson.pub pearson.txt command. However, instead, you enter the following command with only one “e” in zoneexport instead of two:

dnscmd /zonexport pearson.pub pearson.txt

dnscmd gives an error and then displays help. You don’t have to retype the entire command. Instead, you can just press the up arrow to retrieve the command, press the left arrow until the cursor is positioned after zone, add the second e, and then press Enter. The same command executes again without retyping it from scratch.

Tip

After making an edit, you don’t have to reposition the cursor at the end of the line. Simply press Enter to continue.


The following table shows the keys you can use to retrieve commands.

Keyboard KeyDescription
Up arrowRecalls the previous command.
Down arrowRecalls the next command in the doskey buffer.
Page upRecalls the oldest command in the current session.
Page downRecalls the most recent command in the current session.

You can use the following keys when editing a retrieved doskey command.

Keyboard Key or Key CombinationDescription
Left arrowMoves the cursor back one character at a time.
Right arrowMoves the cursor forward one character at a time.
CTRL + left arrowMoves the cursor back one word.
CTRL + right arrowMoves the cursor forward one word.
HomeMoves the cursor to the beginning of the line.
EndMoves the cursor to the end of the line.
EscClears the command from the display.

Note

The doskey buffer holds the last 50 commands by default; however, you can change that with the /listsize switch. For example, to extend the history buffer to 75, use the following command:

doskey /listsize = 75


Tip

You can also change the buffer size by right-clicking the title bar, selecting Properties, and changing the buffer size. The buffer size value is the same as the listsize value.


The following are some of the useful commands you can use with doskey.

doskey CommandDescription
c:\>doskey /historyLists all commands in the history buffer.
F7Displays the command history in a selectable popup dialog box.
c:\>doskey /reinstallInstalls a new copy of doskey.exe and clears the command history buffer.
doskey /listsize = number
c:\>doskey /listsize = 999

Changes the size of the doskey buffer to the provided number. The example sets the buffer size to 999.

4. Creating Mini Macros with doskey

You can create mini macros to make them available to you in a command prompt session. For example, imagine that you expect to enter sc stop netlogon and sc start netlogon many times. You can create two macros with the following commands:

doskey stpnl = sc stop netlogon
doskey sttnl = sc start netlogon

Now, you can simply enter stpnl at the command prompt to stop the netlogon service, and enter sttnl to start it.

Note

Macros are available only in the current session. If you close the command prompt and reopen it, the macro is lost.


doskey CommandDescription
doskey macroKey = command
c:\>doskey stpnl = sc stop netlogon
c:\>doskey sttnl = sc start netlogon

Creates a macro that executes the command when the macro key is entered. The examples create two macros named stop and start that can be used to stop and start the netlogon service.
c:\>stpnl
c:\>sttnl

Executing the macro is the same as executing the command. These examples show how to execute the macros.
c:\>doskey /macrosDisplays all doskey macros in the session.

5. Cutting and Pasting to and from the Command Prompt

You can cut text from, and paste text to, the command prompt. The process is a little different depending on how the Quick Edit Mode option is configured. Figure 4 shows the Options tab of the Properties dialog box. You can access this by right-clicking the title bar of the command prompt window and selecting Properties.

Figure 4. Options tab of Command Prompt Properties window


The QuickEdit Mode option changes the way you can cut and paste from the command line. The Insert Mode option works just like the Insert key of the keyboard. It enables you to insert characters in the line when enabled or overwrite characters in the line when disabled.

Tip

If you want your changes to apply anytime the command prompt window is open instead of only the current session, right-click the title bar, select Defaults, and then select the options.


Copying from the Command Prompt Window

You can copy data from the command line to the Clipboard.

Quick Edit Mode OptionResult
If Quick Edit Mode is enabled (checked)Use the mouse to highlight text and press the Enter key to copy highlighted text.
If Quick Edit Mode is not enabled (unchecked)Right-click in the command prompt window and select Mark.
 Use the mouse to highlight text and press the Enter key to copy highlighted text.

Note

Both of these methods copy the data to the Clipboard. You can then paste it into any other application (such as Notepad).


Pasting Data to the Command Prompt Window

You can paste any data that is in the Clipboard to the command line.

Quick Edit Mode OptionResult
If Quick Edit Mode is enabled (checked)Right-click in the command prompt window and the data is pasted.
If Quick Edit Mode is not enabled (unchecked)Right-click in the command prompt window and select Paste.

Note

If you copy a carriage return with the command, the carriage return is pasted into the command prompt window. In other words, when you paste it, it executes.

 
Others
 
- Windows Server 2008 : Launching and Using the Command Prompt (part 1) - Launching with Elevated Privileges
- Windows 8 : Settings and Customization - Settings
- Windows 8 : Settings and Customization - Control Panels
- Windows Server 2008 : Viewing and Manipulating the Install Mode with change user, Modifying Logon Capabilities with change logon, Connecting and Disconnecting Sessions with tscon and tsdiscon
- Windows Server 2008 : Remote Desktop Services - Adding the Remote Desktop Services Role
- Windows 8 : Configuring User and Computer Policies - Working with Logon and Startup Policies
- Windows 8 : Configuring User and Computer Policies - Working with Computer and User Script Policies
- Managing Windows Small Business Server 2011 : Using Windows Server 2008 R2 Tools (part 2)
- Managing Windows Small Business Server 2011 : Using Windows Server 2008 R2 Tools (part 1)
- Windows 8 : Configuring User and Computer Policies - Working with Access and Connectivity Policies
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us