Windows 10 command line tricks

Windows 10 introduces some handy time-saving features to the Command Prompt, including QuickEdit mode (actually introduced in Windows 8, but let's not split hairs).

This enables you to select and copy text from the console quickly, using the mouse – click and drag to select, then right-click to copy it to the clipboard. Place your cursor where you wish to paste it in the console, and right-click again.

Many commands generate pages and pages of data – to save you the onerous task of scrolling back up to review them, add the | more option onto the end of offending commands, to force them to show the first page, then pause.

Windows 10 command line tricks

From here, press Enter to move down a line at a time, or Space to scroll through the next page.

Alternatively, redirect the information to a text file with the switch – for example, drivequery -v drivers.txt creates the file in your current directory. Some commands can appear to get stuck or keep on looping – break out of them without closing the Command Prompt window by simply pressing Ctrl + C.

Want to clear the screen buffer and start with a fresh new 'page'? Type cls and hit Enter. The Command Prompt also keeps a handy history of previous commands – how many is configured via the 'Options' tab under Command Prompt Properties, which you can cycle through using the up and down cursor keys, speeding up text entry.

Working with Batch Files

Batch files are specially created text files that contain a list of Command Prompt commands, which are executed in the order they're written. They can also be used to call executable programs (use the start command), and are a great way to make repetitive commands easy to process.

Windows 10 command line tricks

You can create and edit batch files in Notepad – place each command with its options on a separate line. When you come to save the file, set 'Save as type:' to 'All Files (*.*)', before giving the file a .cmd extension.

There's a number of commands designed for use in batch files. One of the easiest to use is the pause command. Place this in your batch file, and when it's reached, the Command Prompt throws up a 'Press any key to continue' message, and waits for a key to be pressed.

You can also make use of the echo command to display text on-screen, and insert an @echo off command at the top of your batch file to prevent the commands themselves from appearing in the Command Prompt window as they're run.

Other useful commands include call, which enables you to call a second batch file from within the first, plus choice and set for introducing interactivity through the form of choices for the end user (you can also introduce conditions through the if and goto commands).

Batch files can be run from within the Command Prompt window (you can drag them from File Explorer into the window), or simply by double-clicking them in File Explorer – you'll see the Command Prompt window appear, and it disappears when the script completes.