Wednesday, 22 July 2015

50 most useful Command Prompt commands. Part 1

50 most useful Command Prompt commands

In the first of a new series, Jane Hoskyn introduces your PC’s oldest – and most powerful – hidden tool

The Windows Command Prompt (‘command line’) is your PC’s last living link to MS-DOS. It’s barely aged a day and remains one of Windows’ most powerful tools, but it’s sorely under-used. No surprise, really: it’s stuffed with jargon and looks like something a nostalgic hacker would dream about.

Windows 10 will make the command line a little more user-friendly by letting you paste text into it. But whatever version of Windows you’re using, this age-old tool makes life easier by giving you quick control of tasks that would otherwise involve lots of clicking around in the Control Panel – anything from shutting down your PC to copying multiple files from one directory to another.

Open it by typing cmd into Start and pressing Enter. Type a ‘command’ at the ‘prompt’ (the line of text that starts with ‘C:’ and ends with ‘>’) and then press Enter to carry out your chosen task.

Over the next few issues we’ll reveal some truly powerful and inventive commands, but first here are the 10 Command(ments) for finding your way around the Command Prompt.

1. See a list of commands

Type help at the prompt and press Enter to instantly generate a list of common commands, along with brief details. The list is in capital letters, but you can type commands in lower case (or even a mix) – the command line isn’t case-sensitive.

2. Copy results to the clipboard

Your next instinct may be to save this list of commands to your Desktop for easy reference. However, there’s no File menu and no support for copy and paste (pre-Windows 10, at least), so you can’t just press Ctrl+A then copy and paste everything to Notepad.

But here’s a trick: type space, then | clip after any command, and the results will be automatically copied to your clipboard. For example, type help | clip and press Enter, then open Notepad and press Ctrl+V to paste the list of commands.

3. Find out what a command does

Type a command, then a space, then /? and press Enter to see a description. In some cases you need to type ?/ instead of /?; try both.

4. Command your whole PC

By default, the Command Prompt accesses ‘C:\Users\your name’. To access your entire hard drive instead, type cd\ and press Enter to get a new prompt: ‘C:\>’. Alternatively, specify a directory to work in. For example, type cd\windows\system32 to move the prompt to the ‘system32’ folder, where hidden system files are kept, even in 64bit PCs.

5. See directory contents

Type dir and press Enter to see folders in the current directory. If you’re at the ‘Users’ prompt, for example, you’ll see a list including Desktop, Downloads  and Searches, along with modification dates.

6. See all directory contents

Type tree to see a visual tree of every file in your selected directory. If your prompt is ‘C:\>’ and you’ve had your computer for years, you may need to go and make a cup of tea while the tree populates – but don’t wander far, because it’s fascinating to watch.

7. Get a new prompt

Type cmd or command to generate a new prompt at the same location as your previous prompt. So if you’d been at ‘C:\>’, the new prompt will also be ‘C:\>’. To go back to default, close Command Prompt and start again.

8. Open a new window

Type start to open a second Command Prompt window, showing the same prompt as in the first window.

9. See recent commands

Type doskey /history to see all the commands you’ve typed in the current session.

10. Clear the command window

Type cls to remove everything from the window except the prompt.