For many Windows users, the Command Prompt is unknown territory and that is a missed opportunity because with the Command Prompt you can use your PC even faster and more effectively. For example, there are commands that allow you to perform tasks faster or more accurately, but that is only the tip of the iceberg. We have listed 15 useful commands.
01 To the prompt
To run command line commands, you must first open the command prompt. In Windows 7, you can do this from the start menu, where you successively All Programs / Accessories / Command Prompt select. In Windows 10 (and Windows 8) you can do this by pressing Windows key + X, after which you go to the menu Command Prompt choose. Or you tap cmd in the Windows start window. By default, you end up in the command prompt window without administrator rights. However, if you need extra privileges, click the option in Windows 7 Command Prompt right-click and choose Run as administrator. In Windows 10, press Windows key + X and choose this time Command Prompt (administrator).
02 The command prompt itself
By default you end up in a window with white letters on a black background, but that can be adjusted. You change the colors with the color command (which, like all commands, you close with Enter): color 1E for example gives you blue letters on a light yellow background. The command color /? gives a nice overview of the available colors. With the command cls neatly empty the window. With exit close the window again. If you want to paste further text from Windows into such a command prompt window, first copy that text to the clipboard with Ctrl + C, after which you right-click the title bar of the command prompt window and Edit / Paste choose.
03 Request folder contents
Suppose you want to request the contents of folder c: root subfolder. This is possible with the dir command: dir c: main folder subfolder. Or you navigate to the desired folder with CD root folder, followed by cd subfolder, after which you dir executes. Or easier: you browse in Windows Explorer to the desired folder, after which you click an empty place in the Explorer window with Shift + Right mouse button. Then select in the context menu Open command window here. We’ll stick with the dir command for a while, as it has some interesting parameters, such as dir /? you already make clear. For example, if you want to sort the content by date (most recent files first), you do that with dir / OD.
04 Hidden data streams
Many are unaware that Windows allows different ‘data streams’ to be linked to a file. You can use such an extra data stream to hide data in a file. A small experiment makes that clear. Create (with Notepad) a document you want to hide, for example secret.txt. Then run the following command in that folder: type secret.txt> blabla.txt: hidden.txt. This will include secret.txt in the (apparently empty) blabla.txt file. You can now delete the file secret.txt (for example with del secret.txt). If you run a dir command, blabla.txt will appear empty. However, through the command dir / R you still get to see that hidden data stream. To view the content of that data stream, run the following command: “c: system32 notepad.exe “blabla.txt: hidden.txt.
05 Linked folders
Suppose you need frequent access to a certain folder. That is not very useful when that folder is deeply nested. This can be solved by creating a link to that folder. As an administrator, go to the command prompt and run the following command: mklink / J c: quick folder “d: folder1 subfolder subsubfolder”. When you then save data in the folder c: quick folder, then that data will automatically (also) end up in that deeply nested folder. Afterwards you can delete the ‘link folder’ (c: quick folder) if you prefer; the data in the deeply nested folder is preserved. Note: if you delete files from that link folder, they will also disappear from the deeply nested folder!
06 Services
You probably know that there are a lot of services running in the background in Windows. The command just start tells you exactly which services. Now it is also possible to stop services from the command prompt and start (again). Suppose you want to prevent Windows from restarting your PC just like that because updates are ready, then disable that service with just stop “windows update”. And as you may have guessed, you activate a service with just startfollowed by the exact name of the service. By the way, we use the quotation marks to make it clear that it is a concept (or path), and not individual words.
07 Shared resources
In Windows you can share resources such as printers and folders. To get a quick overview of these shared resources, run the command net view \ in, for example net view \ editorial pc1. You can read that computer name in the window that you see when you Windows key + Pause pressed. You create a new shared network folder with a command like net share videos = “c: media personal video movies”. You can delete the shared network folder with net share videos / delete. It is also possible to permanently attach a shared network disk to a free drive letter: net use x: \ “” / persistent: yes (where you replace x: with the desired drive letter).
08 Accounts with time restrictions
You can perform all kinds of management tasks for Windows accounts via Windows User Account Control. But some tasks can only be performed (or faster) from the command prompt. If you want to temporarily put a certain account on hold, an assignment is sufficient as before user / active: no (replace no with yes to activate it again). Or you can make sure that an account can only log into Windows at specific times: net user / times: Mon-Fri, 5 pm-7pm; Sat-Sun, 10 am-8pm. With net user you check whether the assignment was successful. Note: do not forget the forward slash (for active and times), otherwise Windows will think you want to change the account password!
09 Connectivity
It sometimes happens in a network that a device suddenly stops responding. To quickly find out whether there is still a network connection between your PC and that device, use the ping command, followed by the computer name or IP address of that device (for example ping editorial pc-1 or ping 192.168.0.5). If all goes well, you will get four answers. If not, check the physical connection or network configuration. In many cases you can also test external servers (such as ping www.google.nl). Can you ping an external IP address (such as ping 8.8.8.8), but not the URL, then there may be a problem with the DNS service: see also tip 11.
10 Internet connection
There is also a command that allows you to check the extent of the connection between your own PC and the target server on the Internet. After all, there are often a lot of ‘nodes’ (such as routers) between your PC and such a server and it cannot be ruled out that your connection will fail at one of those nodes. Feel free to try it out with the following command: tracert www.computertotaal.nl. Such a command is also very informative since you can check which route (rs) your request takes. By the way, modern Windows versions also include the command pathping, a combination of ping and tracert. After the trace and some patience, the response statistics will follow.
11 DNS
When you enter a web address (URL) in your browser, a DNS (Domain Name Service) ensures that it is neatly linked to the corresponding IP address, so that your browser can connect to the web server. If you can still reach IP addresses, but no longer URLs, it helps nslookupcommand you to check the operation of the DNS server. Enter nslookup then tap server followed by the name or IP address of the DNS server you want to test. Now press the Enter key and enter any web address, such as www.computertotaal.nl. If you now see timeouts, there is apparently a problem with the set DNS server.
12 Network configuration
A quick way to request all kinds of information about your home network is via the command ipconfig. This way you can see, among other things, which (wireless or not) LAN adapters are active, which IP address those adapters have, and what the address of your default gateway (or router) is, so that you can enter this address in your browser. to go to that device’s web interface. If you also want to know the DNS server (s) and the MAC addresses of the network adapters and if you want to know whether DHCP is active, use ipconfig / all. In case of connection problems, it can also help to release all addresses with ipconfig / release and reset it with ipconfig / renew.
13 Network connections
The command netstat gives you an overview of the active connections, including the IP address and port number of sender and receiver. Also do the assignment netstat /? to get an idea of ​​the numerous parameters. So gives netstat -s you a nice statistical overview per network protocol (IP, ICMP, TCP and UDP), which can be useful in solving network problems. With netstat -o you will also see the PID (process identifier) ​​of the processes. Via Windows Task Manager, where you get View / Select Columns / Process ID you can find out which applications are responsible for it.
14 Copy operations
Chances are that you often copy files and folders via Explorer. However, that environment does not offer much flexibility, at least not when you compare the possibilities with the command robocopy. Through robocopy /? you get an overview of the impressive number of parameters. One example: with robocopy c: media g: backup media / MIR (MIR stands for mirror) the source folder (c: media) is automatically mirrored with the destination folder (g: backup media). The option to save commands is also useful: you only need the parameter / SAVE: to add. With the command robocopy / JOB: do you perform that task properly again.
15 In batch
Another important advantage of command line commands is that you can include several commands in a batch file one after the other, so that they are executed one by one as soon as you call the batch file (the latter can also be done via the Windows task scheduler). Such a batch file is nothing more than a text file with the extension .bat or .cmd, which you create with Notepad, for example. A simple example for illustration:
cls
robocopy c: media g: backup media
del c: media *. * / Q
pause
The del command removes all files from c: media without asking for confirmation (after copying them with the robocopy command).