How to start the Windows Command Prompt, access it from the PowerShell window, and which commands to use.
Ever since Windows 95 was released, the command prompt has been an integral part of the Microsoft operating system. It allows you to quickly execute commands of all kinds using a text-based interface.
Although in the latest Windows 10, it has progressively replaced by Powershell ( Windows PowerShell, how the interface that replaces the command prompt works ); all you need to press the key combination Windows + R then type cmd to open it.
Some operations can only be performed using administrator rights: to open the command prompt with administrative privileges, just type cmd in the Windows search box, then press the key combination CTRL + SHIFT + ENTER.
As we have seen in the article Windows Command Prompt: here is all its potential; some commands made their debut at the time of MS-DOS and are still usable today using the same syntax.
Here are some tricks and secrets to use at the command prompt: some of them will certainly be known to those with decades of experience, but they could still be very useful to everyone else.
1) Open the command prompt from the Powershell window
In the most recent versions of Windows 10, pressing the key combination CTRL + X will find the new entries Windows Powershell and Windows Powershell (administrator). The second allows you to open a Powershell window with administrator rights.
To interact with the historical command prompt and use the usual syntax, just type cmd at the Powershell prompt and press Enter.
2) Open the command prompt from any folder
There is a very handy trick that allows you to open the command prompt or Powershell window from the Windows graphical interface.
It is sufficient to go to the folder of interest, hold down the SHIFT key, and then, right-click in a free area and choose Open command prompt window here or Open Powershell window here.
3) Save the command response as a text file
The > operator allows you to store the output of any command in the form of a text file.
The system info command allows you to collect all the relevant information about the configuration of your system.
To save them as a file, you can type systeminfo>% temp% systeminfo.txt.
In this case, the systeminfo.txt file will be saved in the temporary files folder: the environment variable % temp% is used to refer to it. Instead, you can type % userprofile% to save the file in the folder containing the user profile or specify the full path to any directory.
The response of any command can be redirected within a text file.
4) Concatenate the commands and open the Notepad
Using the following syntax systeminfo>% userprofile% systeminfo.txt && notepad% userprofile% systeminfo.txt, you can produce a text file with the command output. You can use the operator && concatenate the next command, and open Windows Notepad.
5) Save the structure of a folder as a text file
Using the syntax already seen above, it is possible to launch the command tree / a% userprofile%>% userprofile% dir.txt to obtain all the folders contained in the specified path in the form of a text file dir.txt. Instead of the first occurrence of % userprofile%, it is possible to indicate the path object of interest.
6) Copy and paste text to and from the command prompt window
To copy any text string from the command prompt, just select the book of interest with the mouse pointer while keeping the left button pressed.
To copy them to memory in the Windows clipboard area, simply press Enter. No CTRL + C, therefore, because it is a key combination used to interrupt the execution of a command.
To paste a string at the command prompt, we suggest you simply click it with the right mouse button: it will be immediately pasted when contained in the Windows clipboard.
7) Quickly restart your PC and those connected to the local network
To request a quick restart of the operating system, you can use the command shutdown / r / t 0 while the command shutdown / r / o / t 0 will allow you to open the boot settings menu: Windows 10 startup settings menu: what it is and what it is for.
The shutdown / I command, on the other hand, allows you to bring up a dialog box through which you can request a restart, forced shutdown, or shutdown of the work session for any system connected to the local network.
The Remote Shutdown window allows you to specify the PC or devices to control and explain it on the screen.
8) Use the Robocopy command to back up files and folders
Few people know about robocopy – a versatile command that can be used even within batch files and scripts to set up an automatic backup of files and folders’ contents.
The following command allows you to configure an incremental backup without installing third-party utilities, requesting the synchronization of the specified folders at the same time:
robocopy c: users michele documents h: backup documents / copyall / e / r: 0 / dcopy: t / mir
See also Robocopy: How to quickly copy files and folders on the local network.
9) Make sure that a drive letter is associated with a path
The subst command allows you to associate a drive letter with a path.
Thus, by typing subst q:% userprofile% desktop, the folder containing the information saved on the Windows desktop will be accessible from the command prompt, using the drive letter Q:
10) Move programs and folders to other drives avoiding modifying the original paths
Junctions and symbolic links allow you to create pointers to move any program, regardless of the size, from one drive to another without altering either the original paths or their respective references contained in the various areas of Windows and the registry.
The procedure to follow is explained in our article How to move programs from C: to D or other drives.
11) Know the IP addresses used by the network cards
By introducing the ipconfig / all command at the Windows command prompt, you can get the list of IP addresses used by the physical and virtual network cards installed on the system. Just refer to the Link-Local IPv6 Address and the IPv4 Address.
Useful Gateway and Subnet mask to know the router’s IP address and the approach with which private addresses are assigned within the LAN: Subnet mask, what it is, and what it is for.
12) Read the password of any WiFi network in clear text
At the command prompt, by writing netsh wlan show profile name = WIFINAME key = clear, it is possible to display the password of the WiFi network to which you have previously connected.
13) Obtain the list of commands executed at the prompt
By pressing the function key F7, it is possible to access the complete list of commands used previously at the Windows prompt: using the arrow keys, it is possible to repeat operations already carried out.
The F8 key, if pressed repeatedly, allows you to access the previously given commands one after the other; F3, on the other hand, allows you to repeat the last command. The same results can be obtained using the up / down arrow keys.
14) Search in the name of the files and folders stored on the PC
The where the command is also little known: we talked about it in the article Searching for files on the Windows 10 PC: how the new search works as an alternative to the search tools integrated into the operating system interface.
Typing the following will give you the list of files and folders stored on drive E: which contain the term relationship (note the use of the asterisk wildcard):
where / re: “* relationship *” / t
15) Compare the contents of two files
The command fc invocable from the Windows prompt can be used to compare the contents of two files. Our suggestion is to try using the following three commands, depending on the type. In any case, it will be necessary to follow the paths and names of the files to compare, enclosed in quotation marks:
fc / c compare “text only” files
fc / b compare binary files
fc / l compare the ASCII portion of the indicated files
Example: fc / c “c: temp text1.txt” “c: users michele desktop my text.txt“
16) Forcing a program to close
The taskkill command allows you the force closing of a running program from the command prompt. Without opening the Task Manager ( CTRL + SHIFT + ESC ), you can close all instances of the same program and all related processes in one go.
To force closure of a program, you can write taskkill / im progname.exe / f, replacing the executable name appropriately.
Alternatively, knowing the title of the window or windows that stop responding, you can use the following syntax:
taskkill / fi “WINDOWTITLE eq * title *” / f
The string that unites the title of the windows to be closed simultaneously must be indicated in place of the title.
17) Secure deletion of free space
To prevent information already deleted on a storage media from being recovered using the appropriate recovery utilities, Windows offers the cipher utility, which can be easily invoked from the command prompt.
For example, by typing cipher / w: X: , Windows will wipe the free space available on the drive with the identification letter X:
18) Check if a port is open and the server features in use
The command netstat -an allows you to establish all activated and listed connections on your system.
Typing netstat -an | find / i “443”, it is possible to check if a web server or any other program is activated a server component or listed for the arrival of any incoming connection requests on the port is installed on the system in use 443 (HTTPS).
A tech-savvy writer with a knack for finding the latest technology in the market, this is what describes John Carter. With more than 8 years of experience as a journalist, John graduated as an engineer and ventured soon into the world of online journalism. His interest includes gadget reviews, decoding OS errors, hunting information on the latest technology, and so on.