- Command line
- Why do people use the command line?
- Example of doing a task in the command line
- Move all .txt files to a backup directory in a Windows command line
- Move all .txt files to a backup folder in a Windows
- Command line commands
- Text interface with menus in a command line
- Should I learn a command line?
- Should I use «command line» or «command-line» in my writing?
- Find windows OS version from command line
- Find OS Version and Service Pack number from CMD
- Check Windows version using WMIC command
- DISM operating system uninstall command-line options
- /Get-OSUninstallWindow
- /Initiate-OSUninstall
- /Remove-OSUninstall
- /Set-OSUninstallWindow
- Windows commands
- Prerequisites
- Command shell overview
- Command-line reference A-Z
- What Is Command Line and Command Prompt In Windows Operating System?
- Command-Line or Command Prompt
- Running Scripts and Batch Files On-Command Prompts
- MS-DOS Command Prompt
- Open MS-DOS Command Prompt
- PowerShell Command Prompt
- Open PowerShell Command Prompt
- Windows Terminal Command Prompt
- Open Windows Terminal Command Prompt
Command line
The command line, also called the Windows command line, command screen, or text interface, is a user interface that’s navigated by typing commands at prompts, instead of using a mouse. For example, the Windows folder in a Windows command line is «C:\Windows>» (as shown in the picture). In Unix or Linux, it may be «%» or «>» depending on the shell. Unlike a GUI (graphical user interface) operating system, a command line only uses a keyboard to navigate by entering commands and does not utilize a mouse for navigating.
Why do people use the command line?
Although using a command line interface requires the memorization of many different commands, it can be valuable resource and should not be ignored. Using a command line, you can perform almost all the same tasks that can be done with a GUI. However, many tasks can be performed quicker and can be easier to automate and do remotely.
For example, users who have Microsoft Windows may find a task such as renaming 100+ files in a folder, a very time intensive task. However, renaming 100+ files in a directory can be done in less than a minute with a single command in the command line. The task could also be automated using a batch file or other scripts to run instantly.
Example of doing a task in the command line
For someone with little or no experience with a command line, it may be difficult to grasp how the command line is used. Below is an overview to help demonstrate a task done in the Windows command line and in the Windows GUI.
Move all .txt files to a backup directory in a Windows command line
- Open the Windows command line.
- Move to the directory containing the .txt files using the cd command. For example, you could move to the hope user’s documents by typing «cd\users\hope\documents» at the prompt.
- Once in the directory, if a backup directory did not exist you could use the md command and type «md backup» to make a new backup directory.
- Finally, to move all .txt files you could use the move command and type «move *.txt backup» to move all .txt files to the backup folder. The * is used as a wildcard.
Move all .txt files to a backup folder in a Windows
For a comparison to the above command line steps. Below are the steps on how to perform the same action (moving .txt files) in Windows.
- Open Windows Explorer.
- Open the drive and folder containing the .txt files. For example, you could move into the C: drive and navigate to the Users folder, Hope folder, and then the Documents folder to open them for the hope user.
- Once in the folder, if a backup folder did not exist, you could right-click in the folder, click New, select Folder, and name it «backup» to create a new backup folder.
- If Windows Explorer is not showing the files in the Details view, click the View tab and select Details.
- Click the Type column to browse files by type.
- Highlight all .txt files.
- How to select or highlight multiple files and folders.
- Right-click the highlighted and select Cut.
- Open the backup folder, and in that folder, right-click and then click Paste to move all files into that folder.
As demonstrated in the two examples above, performing the same task in a command line does require learning at least three commands. However, once these commands are known, it requires less steps in a command line than in Windows. These same commands could also be used in a batch file or other scripting language to automate the process. For example, you could automate backing up files by copying the files instead of moving them. Once the commands are written in a batch file, double-click the batch file to perform all the copying.
Command line commands
There are hundreds of different commands that can be used in a command line. Remembering all the commands, syntax, and options of every command would be impossible, which is why we’ve created the below pages. Below are links to our Windows command line, MS-DOS, Linux, and Unix command listings. Each of these pages has hundreds of commands with full syntax and examples of how to use each command.
Text interface with menus in a command line
A text interface can be made easier to navigate using menus created with text and ASCII extended characters. For example, many command line text editors use an interface with menus and shortcut keys that make navigating the file being edited easier. The picture below is an example of the MS-DOS editor used to edit files while at the MS-DOS or Windows command line.
Although a text interface with menus has a lot more visual appeal than the command line, this interface is still considered a text interface and not a graphical interface.
Should I learn a command line?
We’re strong believers you should learn as much as you can about computers to make using a computer easier. Having a basic understanding of the command line from reading this page gives you a much greater advantage than someone unfamiliar with its capabilities. Below are some reasons you may want to learn even more about the command line.
- You need ways to manage files faster and easier on a computer.
- You work with computers remotely.
- Manage files on a file server or web server (e.g., managing a web page).
- Need to automate commonly performed tasks.
- Want to learn even more about computers.
Should I use «command line» or «command-line» in my writing?
Both «command line» and «command-line» are acceptable and widely used in today’s writing. When used as an adjective before a noun, use «command-line» (with a hyphen) in your writing to help prevent confusion. For example, in the sentence «Make sure you entered the correct command-line parameter.» the word «command-line» is describing a type of parameter.
When used as a noun, use «command line» (with no hyphen) in your writing. For example, in the sentence «Open the command line.» the use of «command line» is used as a noun.
Find windows OS version from command line
Windows has command line utilities that show us the version of the Windows OS running on the computer, including the service pack number. There are multiple CMD commands that help with finding this, you can pick the one that suits your need. Ver command can show you the OS version whereas Systeminfo command can additionally give you service pack, OS edition and build number etc.
Find OS Version and Service Pack number from CMD
As you can see above, ver command shows only OS version but not the service pack number. We can find service pack number as well with Systeminfo command. Systeminfo dumps lot of other information too, which we can filter out using findstr command.
This command works on XP, Vista and Windows 7 and on Server editions also. Find below example for Win7.
In case of Windows 7 SP1, the output would be slightly different as below.
If you want to print more details, then you can use just ‘OS’ in the findstr search pattern. See example below for Server 2008.
Check Windows version using WMIC command
Run the below WMIC command to get OS version and the service pack number.
Example on Windows 7:
If you want to find just the OS version, you can use ver command. Open command window and execute ver command. But note that this does not show service pack version.
This command does not show version on a Windows 7 system.
DISM operating system uninstall command-line options
OEMs shouldn’t use this setting in imaging or manufacturing scenarios. This setting is for IT administrators.
Windows gives a user the ability to uninstall and roll back to a previous version of Windows. You can use DISM to:
- Find out how many days after an upgrade that an OS can be uninstalled
- Initiate an uninstall
- Remove the ability for a user to uninstall a Windows upgrade
- Set the number of days that a user has to uninstall a Windows upgrade
/Get-OSUninstallWindow
Run this command against an online image to see how many days after an upgrade that an uninstall can be initiated.
/Initiate-OSUninstall
Run this command against an online image to revert a PC to a previous Windows installation.
By default, you will be prompted to restart the PC after running this command. You can choose to suppress the prompt by either specifying the /Quiet option, which allows the restart the happen automatically, or specifying the /NoRestart option, which will require the PC to be restarted manually.
Note: The /NoRestart and /Quiet options are new in Windows 10 Version 2004. In earlier versions of Windows 10, seccessful execution of this command does not produce any output, and the PC must be restarted manually. Running the command again after it has already succeeded will result in ERROR_NOT_FOUND (1168), but the uninstall will continue to proceed once the PC restarts.
/Remove-OSUninstall
Run this command against an online image to remove the ability to roll back a PC to a previous installation of Windows.
/Set-OSUninstallWindow
Run this command against an online image to set the number of days after an upgrade that an uninstall can be initiated.
If value passes anything 60, the default value of 10 will be set
Windows commands
All supported versions of Windows (server and client) have a set of Win32 console commands built in.
This set of documentation describes the Windows Commands you can use to automate tasks by using scripts or scripting tools.
Prerequisites
The information that is contained in this topic applies to:
- Windows Server 2019
- Windows Server (Semi-Annual Channel)
- Windows Server 2016
- Windows Server 2012 R2
- Windows Server 2012
- Windows Server 2008 R2
- Windows Server 2008
- Windows 10
- Windows 8.1
Command shell overview
The Command shell was the first shell built into Windows to automate routine tasks, like user account management or nightly backups, with batch (.bat) files. With Windows Script Host you could run more sophisticated scripts in the Command shell. For more information, see cscript or wscript. You can perform operations more efficiently by using scripts than you can by using the user interface. Scripts accept all Commands that are available at the command line.
Windows has two command shells: The Command shell and PowerShell. Each shell is a software program that provides direct communication between you and the operating system or application, providing an environment to automate IT operations.
PowerShell was designed to extend the capabilities of the Command shell to run PowerShell commands called cmdlets. Cmdlets are similar to Windows Commands but provide a more extensible scripting language. You can run Windows Commands and PowerShell cmdlets in Powershell, but the Command shell can only run Windows Commands and not PowerShell cmdlets.
For the most robust, up-to-date Windows automation, we recommend using PowerShell instead of Windows Commands or Windows Script Host for Windows automation.
You can also download and install PowerShell Core, the open source version of PowerShell.
Incorrectly editing the registry may severely damage your system. Before making the following changes to the registry, you should back up any valued data on the computer.
To enable or disable file and directory name completion in the Command shell on a computer or user logon session, run regedit.exe and set the following reg_DWOrd value:
To set the reg_DWOrd value, use the hexadecimal value of a control character for a particular function (for example, 0 9 is Tab and 0 08 is Backspace). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.
Command-line reference A-Z
To find information about a specific command, in the following A-Z menu, click the letter that the command starts with, and then click the command name.
What Is Command Line and Command Prompt In Windows Operating System?
Command prompt or command line is a text-based interface used to run commands on the Windows operating system. Command prompt or command line is the generic name of the interface where it can be MS-DOS, PowerShell, or newly released Windows Terminal. In this tutorial, we will learn “What is Command-Line or Command Prompt?” with its uses, commands, scripts, and batch files.
Command-Line or Command Prompt
We will start the terms with Command-Line and Command Prompt . We can see both of these terms in documents and they are used interchangeably which means both Command-Line and Command Prompt terms are used to express and specify the same thing. Some time with the old habits they are named DOS prompt . From now we will use only the Command Prompt .
Running Scripts and Batch Files On-Command Prompts
As running commands on command prompt are trivial task system administrators generally uses scripts and batch files. Script or batch files are used to store multiple commands in a single file and call these commands just running the file as script or batch file.
MS-DOS Command Prompt
MS-DOS is an operating system that is created in the 1980s. But with the development of the GUI, the MS-DOS operating system turned into a Command prompt for most of the users. MS-DOS provides command prompt for Windows users like Windows XP, Windows 7, Windows 8, Windows 10, and all Windows Server versions from 2003. MS-DOS command prompt provides a lot of commands in order to manage the system and operating system.
Open MS-DOS Command Prompt
We can start MS-DOS command prompt in different ways but we will examine the most simple and popular ways to open MS-DOS prompt. Open the Run with WIN+R keyboard short cut or from the Start Menu . And then write cmd.exe or cmd then press enter.
We will see the following MS-DOS command prompt.
PowerShell Command Prompt
PowerShell is a next-generation command prompt for the Windows operations systems. It is a lot more advanced than then MS-DOS command prompt. PowerShell provides complete programming and scripting environment which is tightly integrated with the .Net Framework and Windows operating system. PowerShell provides an alias for the Linux commands which makes migration from the Linux command line or Bash to the PowerShell.
Open PowerShell Command Prompt
We can open a PowerShell command prompt in different ways. First from the Start Menu write PowerShell to the Search/Run Box where PowerShell will be listed like below.
Or we can open from Run which can be opened with the WIN+R keyboard shortcut and write the powershell to the box like below.
We will see the following PowerShell command prompt. We can see that in order to specify the current command line is PowerShell PS added before the command prompt.
Windows Terminal Command Prompt
Windows Terminal is the latest command prompt provided by Microsoft. It is released in 2019 which provides modern terminal features that are already provided by most of the Linux terminals. Windows terminal is actually just a GUI that can provide both MS-DOS and PowerShell command line in a tabbed manner.
Open Windows Terminal Command Prompt
We can open Windows Terminal from the Start Menu just typing Windows Terminal like below. And then click Open or Run as Administrator in order to run with Administrative privileges.