15 Useful Commands in Windows Command Prompt

For many Windows users, the Command Prompt is unfamiliar territory and that is a missed opportunity because the Command Prompt can help you use your PC even faster and more effectively. There are commands that allow you to perform tasks faster or more accurately, but that's just the tip of the iceberg. We list 15 useful commands.

01 To the prompt

To run command-line commands, you must first open the Command Prompt. This is possible in Windows 7 from the start menu, where you successively All Programs / Accessories / Command Prompt selects. In Windows 10 (and Windows 8) you can do this by pressing Windows key + X, after which you go to the menu Command Prompt chooses. Or you tap cmd in the Windows start screen. By default, you will end up in the Command Prompt window without administrator rights. However, if you need extra permissions, 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 (Admin).

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 clear the window properly. Of exit close the window again. If you also want to paste 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 chooses.

03 Request folder contents

Suppose you want to retrieve the contents of folder c:\root\subfolder. You can do that with the dir command: dir c:\root\subfolder. Or you navigate to the desired folder with cd root, followed by cd subfolder, after which you dir performs. Or easier: you browse to the desired folder in Windows Explorer, after which you click an empty space 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, because it has some interesting parameters, like dir /? you already make clear. For example, if you want to sort the content by date (latest files first), you can do that with dir /O-D.

04 Hidden data streams

Many do not know that Windows allows several '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 that 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 (seemingly empty) file blabla.txt. You may now delete the file secret.txt (for example with share secret.txt). When you run a dir command, blabla.txt appears empty. However, via the command dir /R you still get to see that hidden data stream. To see the contents 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:\shortcut "d:\folder1\subfolder\subsubfolder". When you then save data in the folder c:\shortcut, then that data automatically (also) ends up in that deeply nested folder. Afterwards you can remove the 'link folder' (c:\shortcut) again if you prefer; the data in the deeply nested folder is preserved. Note: when 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 starting tells you exactly which services. Now it is also possible to stop and restart services from the command prompt. Suppose you want to prevent Windows from restarting your PC because there are updates ready, then you disable that service with net stop "windows update". And as you might have guessed, you activate a service with just starting, followed by the exact name of the service. Incidentally, we use the quotation marks to make it clear that it concerns a concept (or path), and therefore not individual words.

07 Shared Resources

In Windows, you can share resources such as printers and folders. If you want to quickly get an overview of these shared resources, enter the command net view \ in, for example net view \editor pc1. You can read that computer name in the window that you see when you Windows key+Pause presses. 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 drive to a free drive letter: net use x: \""\ /persistent:yes (where you replace x: with the desired drive letter).

08 Time-Restricted Accounts

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 suspend a certain account, an order like net . is sufficient user /active:no (replace no with yes to reactivate it). Or you can make sure that an account can only log in to Windows at certain times: net user /times:Mon-Fri,5pm-7pm;Sat-Sun,10am-8pm. Of net user check if the command was successful. Note: do not forget the forward slash with these commands (before active and times), otherwise Windows thinks 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 a network connection still exists between your PC and that device, use the ping command, followed by the computer name or IP address of that device (for example ping editor pc-1 or ping 192.168.0.5). If it is correct, you will get four answers. If not, check the physical connection or network configuration. In many cases, you can also test remote 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, 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 how far the connection between your own PC and the target server on the Internet extends. 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. Please try it out with the following command: tracert www.computertotaal.nl. Such a command is also very informative, as you can check which route(s) your request is taking. By the way, modern Windows versions also contain the command pathping, a combination of ping and tracert. After the tracking and some patience, the reaction 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 can no longer reach URLs, it helps nslookupcommand you to check the operation of the DNS server. feed nslookup off and 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 configured dns server.

12 Network Configuration

A quick way to request all kinds of information about your home network is via the command ipconfig. In this way you can see, among other things, which LAN adapters (whether or not wireless) are active, which IP address those adapters have, and what the address of your default gateway (or router) is, so that you can type this address into 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. Furthermore, it can help with connection problems 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 the sender and receiver. Also do the command netstat /? to get an idea of ​​the numerous parameters. So gives netstat -s gives you a nice statistical overview per network protocol (IP, ICMP, TCP and UDP), which can be useful when solving network problems. Of netstat -o you will also see the PID (process identifier) ​​of the processes. Through Windows Task Manager, where you View / Select Columns / Process ID then 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: then execute that command neatly again.

15 Batch

An important advantage of command-line commands is that you can include several commands one after the other in a batch file, 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 to illustrate:

cls

robocopy c:\media g:\backup\media

del c:\media\*.* /Q

pause

The del command removes all files from c:\media without being prompted for confirmation (after copying them with the robocopy command).

Recent Posts

$config[zx-auto] not found$config[zx-overlay] not found