The Windows command line is one of the most powerful utilities on a Windows PC. With it, you can interact with the OS directly and do a lot of things not available in the graphical user interface (GUI).
In this article, I’ll show you 40 commands you can use on the Windows command line that can boost your confidence as a Windows user.
N.B.: You have to be careful while using the commands I’ll show you. This is because some commands can have a lasting negative or positive effect on your Windows PC until you reset it.
In addition, some of these commands require you to open the command prompt as an admin.
powershell start cmd -v runAs
– Run the Command Prompt as an Administrator
Entering this command opens another command prompt window as an administrator:
driverquery
– Lists All Installed Drivers
It is important to have access to all drivers because they often cause problems.
That’s what this command does – it shows you even the drivers you won’t find in the device manager.
chdir
or cd
– Changes the Current Working Directory to the Specified Directory
systeminfo
– Shows Your PC’s Details
If you want to see more detailed information about your system you won’t see in the GUI, this is the command for you.
set
– Shows your PC’s Environment Variables
prompt
– Changes the Default Text Shown before Entering Commands
By default, the command prompt shows the C drive path to your user account.
You can use the prompt
command to change that default text with the syntax prompt prompt_name $G
:
N.B: If you don’t append $G
to the command, you won’t get the greater than symbol in front of the text.
clip
– Copies an Item to the Clipboard
For example, dir | clip
copies all the content of the present working directory to the clipboard.
You can type clip /?
and hit ENTER
to see how to use it.
assoc
– Lists Programs and the Extensions They are Associated With
title
– Changes the Command Prompt Window Title Using the Format title window-title-name
fc
– Compares Two Similar Files
If you are a programmer or writer and you want to quickly see what differs between two files, you can enter this command and then the full path to the two files. For example fc “file-1-path” “file-2-path”
.
cipher
– Wipes Free Space and Encrypts Data
On a PC, deleted files remain accessible to you and other users. So, technically, they are not deleted under the hood.
You can use the cipher command to wipe the drive clean and encrypt such files.
netstat -an
– Shows Open Ports, their IP Addresses and States
ping
– Shows a Website IP Address, Lets you Know How Long it Takes to Transmit Data and a Get Response
color
– Changes the Text Color of the Command Prompt
Enter color attr
to see the colors you can change to:
Entering color 2
changes the color of the terminal to green:
for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @echo %j | findstr -i -v echo | netsh wlan show profiles %j key=clear
– Shows All Wi-Fi Passwords
ipconfig
– Shows Information about PC IP Addresses and Connections
This command also has extensions such as ipconfig /release
, ipconfig /renew
, and ipconfig /flushdns
which you can use to troubleshoot issues with internet connections.
sfc
– System File Checker
This command scans your computer for corrupt files and repairs them. The extension of the command you can use to run a scan is /scannow
.
powercfg
– Controls Configurable Power Settings
You can use this command with its several extensions to show information about the power state of your PC.
You can enter powercfg help
to show those extensions.
For example, you can use powercfg /energy
to generate a battery health report.
The powercfg /energy
command will generate an HTML file containing the report. You can find the HTML file in C:Windowssystem32energy-report.html
.
dir
– Lists Items in a Directory
del
– Deletes a File
attrib +h +s +r folder_name
– Hides a Folder
You can hide a folder right from the command line by typing in attrib +h +s +r folder_name
and then pressing ENTER
.
To show the folder again, execute the command – attrib -h -s -r folder_name
.
start website-address
– Logs on to a Website from the Command Line
tree
– Shows the Tree of the Current Directory or Specified Drive
ver
– Shows the Version of the OS
tasklist
– Shows Open Programs
You can do the same thing you do with the task manager with this command:
The next command shows you how to close an open task.
taskkill
– Terminates a Running Task
To kill a task, run taskkill /IM "task.exe" /F
. For example, taskkill /IM "chrome.exe" /F
:
date
– Shows and Changes the Current Date
time
– Shows and Changes the Current Time
vol
– Shows the Serial Number and Label Info of the Current Drive
dism
– Runs the Deployment Image Service Management Tool
CTRL + C
– Stops the Execution of a Command
-help
– Provides a Guide to other Commands
For example, powercfg -help
shows how to use the powercfg
command
echo
– Shows Custom Messages or Messages from a Script or File
You can also use the echo
command to create a file with this syntax echo file-content > filename.extension
.
mkdir
– Creates a Folder
rmdir
– Deletes a Folder
N.B.: The folder must be empty for this command to work.
more
– Shows More Information or the Content of a File
move
– Moves a File or Folder to a Specified Folder
ren
– Renames a File with the Syntax ren filename.extension new-name.extension
cls
– Clears the Command Line
In case you enter several commands and the command line gets clogged up, you can use cls
to clear all entries and their outputs.
exit
– Closes the Command Line
shutdown
– Shuts down, Restarts, Hibernates, Sleeps the Computer
You can shut down, restart, hibernate, and sleep your PC from the command line.
Enter shutdown
in the command line so you can see the extensions you can use to perform the actions. For example, shutdown /r will restart your computer.
Conclusion
This article showed you several “unknown-to-many” commands you can use to get access to hidden functionalities on your Windows PC.
Again, you should be careful while working with these commands because they can have a lasting effect on your OS.
If you find the commands helpful, share the article with your friends and family.
In case you know another useful command I did not list, tell me about it on Twitter. I will add it and mention you as the source.
Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started
Download Article
Download Article
This wikiHow teaches you how to run a batch file (.BAT) from the Windows command line. You can run the program from the “Run” dialog or by typing commands into a terminal window.
-
1
Press ⊞ Win+R. This opens the Run dialog.
- If you need to run the batch file as an administrator, see this method instead.
-
2
Click Browse….
Advertisement
-
3
Navigate to the folder that contains the batch file.
-
4
Click the batch file once to select it. The file is now highlighted.
-
5
Click Open. This pastes the full path to the batch file into the Run box.
-
6
Click OK. The batch file will open in a terminal window and run. When it’s finished running, you’ll see a line at the bottom of the window that says “Press any key to continue.”
-
7
Press any key. This closes the terminal window after the command runs.
Advertisement
-
1
Click the
menu. It’s usually at the bottom-left corner of the screen.
-
2
Type cmd into the search bar. A list of matching results will appear.
-
3
Right-click Command Prompt. A menu will expand.
-
4
Click Run as Administrator. A confirmation message will appear.
-
5
Click Yes. This opens the command line at an elevated (administrator) level.
-
6
Type cd followed by full path to the folder with the .BAT file. Here’s an example:
- If the batch file is on your desktop, type cd UsersYourLoginNameDesktop.
- If it’s in your downloads folder, type cd UsersYourLoginNameDownloads.
- If you don’t know what your login name is, type cd Users and press ↵ Enter to go to the Users folder, and then type dir and press ↵ Enter to see a list of logins.
-
7
Press ↵ Enter. This will move you into the directory.
-
8
Type the name of the batch file. For example, if it’s called “program.bat,” type program.bat.
- If you don’t know the name, type dir and press ↵ Enter to view the files in the folder. You’ll find it there.
-
9
Press ↵ Enter. This runs the batch file.
Advertisement
Add New Question
-
Question
It gives an error saying «The input line is too long. The syntax of the command is incorrect.»
Double-check the code, as there’s a command that was not correctly written. Ensure all spaces and special characters are in the proper places.
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Thanks for submitting a tip for review!
About This Article
Article SummaryX
1. Press the Windows + R keys.
2. Click Browse.
3. Select the .bat file.
4. Click Open.
5. Click OK.
Did this summary help you?
Thanks to all authors for creating a page that has been read 268,057 times.
Is this article up to date?
Updated: 12/31/2020 by
This page covers the basics of navigating and using the Microsoft Windows command line. On this page, you learn how to move around in the command line, find files, manipulate files, and other important commands. Realize that there are over 100 different commands used in MS-DOS and the Windows command line. If you are interested in learning about the command line in more detail, see our DOS and command prompt overview, which gives a description and example for every command.
Get into the Windows command line
Open a Windows command line window by following the steps below. If you need additional information or alternative methods for all versions of Windows, see: How to get to an MS-DOS prompt or Windows command line.
- Click Start.
- In the Search or Run line, type cmd (short for command), and press Enter.
Understanding the prompt
After following the steps above, the Windows command line should be shown (similar to the example below). Windows often starts you at your user directory. In the example below, the user is Mrhope. So, C:UsersMrhope> is our prompt. This prompt shows that we’re in the C: drive (default hard drive letter) and currently in the Mrhope directory, a subdirectory of the Users directory.
Key tips
- MS-DOS and the Windows command line are not case-sensitive.
- The files and directories shown in Windows are also found in the command line.
- When working with a file or directory with a space, surround it in quotes. For example, the directory My Documents would be «My Documents» when typed.
- File names can have a long file name of 255 characters and a three character file extension.
- When a file or directory is deleted in the command line, it is not moved into the Recycle Bin.
- If you need help with any of command, type /? after the command. For example, dir /? would give the options available for the dir command.
Listing the files
Let’s learn your first command. Type dir at the prompt to list files in the current directory. You should get an output similar to the example image below. Without using any dir options, this is how dir output appears. As shown, you are given information including the creation date and time, directories (<DIR>), and the name of the directory or file. In the example below, there are 0 files listed and 14 directories, indicated by the status message at the bottom of the output.
Every command in the command line has options, which are additional switches and commands that can be added after the command. For example, with the dir command, you can type dir /p to list the files and directories in the current directory one page at a time. This switch is useful to see all the files and directories in a directory with dozens or hundreds of files. Each of the command options and switches is listed in our DOS command overview. We offer guides for individual commands, as well. For example, if you want to see all the options for the dir command, refer to our dir command overview for a complete option listing.
The dir command can also be used to search for specific files and directories using wildcards. For example, to list files or directories that begin with the letter «A» you could type dir a* to list only the AppData directory, in this above example. See the wildcard definition for other examples and help with using wildcards.
- How to list files in a directory or folder on the computer.
Moving into a directory
Now that we’ve seen a list of directories (shown below) in the current directory, move into one of those directories. To move into a directory, we use the cd command, so to move into the Desktop type cd desktop and press Enter. Once you’ve moved into a new directory, the prompt changes. So, in our example, the prompt is now C:UsersMrhopeDesktop>. You can see what files are found in this directory by typing the dir command again.
- How to change a directory or open a folder.
Understand the files
In the Desktop directory, as shown in the above example, there are 23 files and 7 directories, representing different file types. In Windows, you are familiar with files having icons that help represent the file type. In the command line, the same thing is accomplished by the file extensions. For example, «forum posts.txt» is a text file because it has a .txt file extension. Time.mp3 is an MP3 music file and minecraft.exe is an executable file.
- Listing of file extensions and additional help with file extensions.
Most users are only concerned with executable files, which as mentioned above, are files ending with .exe, .com, and .bat. When the file name is typed in the command line, the program runs, which is the same as double-clicking a file in Windows. For example, if we wanted to run minecraft.exe, typing minecraft at the prompt runs that program.
Note
Realize that if the executable file you are trying to run is not in the current directory, you get an error. Unless you have set a path for the directory with the executable file, which is how the command line finds external commands.
If you want to view the contents of a file, most versions of the command line use the edit command. For example, if we wanted to look at the log file hijackthis.log, we would type edit hijackthis.log at the prompt. For 64-bit versions of Windows that do not support this command, you can use the start command (e.g., type start notepad hijackthis.log) to open the file in Notepad. Additional information about opening and editing a file from the command line is available on the page linked below.
- How to open, view, and edit the contents of a file on a computer.
Moving back a directory
You learned earlier the cd command can move into a directory. This command also lets you go back a directory by typing cd.. at the prompt. When this command is typed, you’ll be moved out of the Desktop directory and back into the user directory. To move back to the root directory type cd to get to the C:> prompt. If you know the name of the directory you want to move into, you can also type cd and the directory name. For example, to move into C:Windows>, type cdwindows at the prompt.
- How to change a directory or open a folder.
Creating a directory
Now with your basic understanding of navigating the command line, let’s start creating new directories. To create a directory in the current directory, use the mkdir command. For example, create a directory called «test» by typing mkdir test at the prompt. If created successfully, you are returned to the prompt with no error message. After the directory is created, move into that directory with the cd command.
- How to create a directory or folder.
Switching drives
In some circumstances, you may want to copy or list files on another drive. To switch drives in the Windows command line, type the drive letter of the drive followed by a colon. For example, if your CD-ROM drive is the D drive, you would type d: and press Enter. If the drive exists, the prompt changes to that drive letter. If the drive does not exist or is not accessible (e.g., no disc in CD-ROM drive), you get an error.
- How to copy files from one drive to another drive.
- How to change drives in MS-DOS and Windows command line.
Creating a new file
You can create a new file from the command line using the edit command, copy con command, or using the start command to open a file.
- How to create a file in MS-DOS and the Windows command line.
Creating a new batch file
In the new test directory, let’s create your first file. In most circumstances, you never need to create any file at the command line, but it is still good to understand how files are created. In this example, we are creating a batch file. A batch file is a file that ends with .bat and helps automate frequently used commands in the command line. We are calling this batch file example, so type edit example.bat at the prompt. As mentioned in the document on creating a file, if the edit command does not work, use the start command to open the batch file in Notepad. To perform this action, you type start notepad example.bat into the prompt.
Both of the commands above open a new blank example.bat window. In the file, type the three lines below, which clear the screen with the cls command and run the dir command.
@echo off cls dir
After these three lines are typed into the file, save, and exit the file. If you are in the edit command, click File (or press Alt+F) and then Save. After the file is saved and you are back at the command prompt, typing dir displays the «example.bat» file in the test directory.
Now, run the batch file to get a better understanding of what a batch file does. To run the batch file, type example at the prompt, which executes the batch file, clears the screen, and runs the dir command.
- Full information and additional examples on batch files.
Moving and copying a file
Now that we’ve created a file, let’s move it into an alternate directory. To help make things easier, create another directory for the files. So, type mkdir dir2 to create a new directory in the test directory called dir2. After the new directory is created, use the move command to move the example.bat file into that directory. To do this, type move example.bat dir2 at the prompt. If done successfully, you get a message indicating the file was moved. You could also substitute the move command for the copy command to copy the file instead of moving it.
- How to move files and folders on the computer.
- How to copy files.
Rename a file
After the file is moved into the dir2 directory, move into that directory with the cd command to rename the file. In the dir2 directory, use the rename command to rename the example file into an alternate name. Type rename example.bat first.bat at the prompt to rename the file to «first.bat.» Now, when using the dir command, you see «first.bat» as the only file.
Tip
When renaming any file, make sure the file has the same file extension. If you were to rename the .bat file to a .txt file, it is no longer an executable file only a text file. Also, realize that renaming the file to a different file extension does not convert the file. For example, if you renamed the file as an .MP3, it may look like an MP3 in Windows, but it’s not going to play music.
- How to change or rename a file, folder, or directory.
Deleting a file
Now that we’ve had our fun with our new file, delete the file with the del command. Type del first.bat to delete the first.bat file. If successful, you are returned to the prompt with no errors, and the dir command shows no files in the current directory.
Tip
When deleting files, you can also use wildcards to delete multiple files at once. For example, if the directory contained several .GIF image files you could type del *.gif to delete all files ending with the .gif file extension.
- How to delete a file, directory, or folder.
Renaming a directory
Go back one directory to get back to the test directory using the cd.. command mentioned earlier. Now, rename our dir2 directory to something else using the same rename command we used earlier. At the prompt, type rename dir2 hope to rename the directory to «hope.» After this command is completed, type dir and you see one directory called «hope.»
- How to change or rename a file, folder, or directory.
Removing a directory
While still in the test directory, remove the hope directory using the rmdir command. At the prompt, type rmdir hope to remove the hope directory.
Tip
If the directory you are trying to remove contains any files or directories, you’ll receive an error. To prevent this error, use the /s option. For example, if the hope directory still had the first.bat file, you would need to type rmdir /s hope at the prompt.
- How to delete a file, directory, or folder.
Running a program
Any executable file can run from the command line by typing the name of the file. For example, if you listed files using the dir command and see a file named «myfile.exe,» typing «myfile» at the command line runs that program.
- How to run a file from MS-DOS.
How to list available commands
After getting a good understanding of using the command line from the steps shown above, you can move on to other available commands by typing help at the command line. Typing «help» displays a list of available commands with a brief description of each command.
Closing or exiting the command line window
After you are done with the Windows command line, you can type exit to close the window.
In conclusion
Now you have a good understanding of how to navigate the command line, create directories and files, rename directories and files, and delete. As mentioned earlier, there are hundreds of other commands you can use at the command line. If you want to expand your knowledge further, we recommend looking at the options available for each command above and reviewing our commands overview page. You can also use our search to find any command by the name of the command or by the action it performs.
I’m trying to programmatically execute an external file from cmd
using this command:
START "filepath"
Where "filepath"
is the path of my file. It opens fine but it also open a new command prompt window.
So, which is the right command for opening an external program without opening a new window?
daaawx
3,1232 gold badges16 silver badges16 bronze badges
asked Aug 17, 2012 at 17:07
3
In Windows 7+ the first quotations will be the title to the cmd
window to open the program:
start "title" "C:pathprogram.exe"
Formatting your command like the above will temporarily open a cmd
window that goes away as fast as it comes up so you really never see it. It also allows you to open more than one program without waiting for the first one to close first.
daaawx
3,1232 gold badges16 silver badges16 bronze badges
answered Jun 25, 2013 at 13:11
Matt — MCTSMatt — MCTS
2813 silver badges3 bronze badges
2
Add /B, as documented in the command-line help for start:
C:>start /?
Starts a separate window to run a specified program or command.
START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
[command/program] [parameters]
"title" Title to display in window title bar.
path Starting directory.
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application.
answered Aug 17, 2012 at 17:15
John WattsJohn Watts
8,6271 gold badge30 silver badges35 bronze badges
1
Just remove the double quote, this works in Windows 7:
start C:ProgramFilesfolderNameapp.exe
If you want to maximize the window, try this:
start /MAX C:ProgramFilesfolderNameapp.exe
Your command START "filepath"
will start a command prompt and change the command prompt title to filepath
.
Try to run start /?
in windows command prompt and you will get more info.
answered Dec 12, 2013 at 2:15
FrankFrank
5928 silver badges27 bronze badges
2
I think if you closed a program
taskkill /f /im "winamp.exe"
//....(winamp.exe is example)...
end, so
if you want to start a program that you can use
start "" /normal winamp.exe
(/norma,/max/min are that process value cpu)
ALSO
start «filepath»
if you want command line without openning an new window
you write that
start /b «filepath»
/B is Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application.
answered Apr 21, 2016 at 12:50
lscodexlscodex
1501 gold badge5 silver badges17 bronze badges
If you’re doing it via CMD as you say, then you can just enter the command like so:
pathtoyour.exe
which will open it within the same window. For example in C++:
system("path\to\your.exe"); // Double backslash for escaping
will open your.exe
in the current CMD window. Likewise to start with a new window, just go for:
system("start path\to\your.exe");
If you go for the first option, you would have to clear your screen unless you wanted to have the command to open your.exe
on the screen still.
answered Mar 11, 2013 at 13:37
whitfinwhitfin
4,4396 gold badges39 silver badges66 bronze badges
You can use the call
command…
Type: call /?
Usage: call [drive:][path]filename [batch-parameters]
For example call "Example File/Input File/My Program.bat"
[This is also capable with calling files that have a .exe, .cmd, .txt, etc.
NOTE: THIS COMMAND DOES NOT ALWAYS WORK!!!
Not all computers are capable to run this command, but if it does work than it is very useful, and you won’t have to open a brand new window…
answered Mar 16, 2016 at 17:52
I got it working from qkzhu but instead of using MAX change it to MIN and window will close super fast.
@echo off
cd "C:Program Files (x86)MySQLMySQL Server 5.6bin"
:: Title not needed:
start /MIN mysqld.exe
exit
answered May 27, 2016 at 14:28
Shersha FnShersha Fn
1,4313 gold badges25 silver badges34 bronze badges
20190907
OS: Win 10
I’m making an exe in c++, for some reason usting START make my program fail.
So, just use quotes:
«c:folderprogram.exe»
answered Sep 7, 2019 at 10:24
It’s easier and safer to use the explorer.exe to start files/executeables, it is also opening files with the associated program and runs executables directly, if you execute:
start "" "%windir%explorer.exe" "C:PathTosome.pdf"
If *.PDF
files are not associated with any program. This works similar to a double-click and triggers the «open with program» dialog.
start "" "%windir%explorer.exe" "%windir%system32calc.exe"
Will bring up the calculator.
start "" "%windir%explorer.exe" "C:pagefile.sys"
Will bring up a warning like: You are trying to open a system file (*.sys)… choose a programm…
Important
explorer.exe always requires the full path to the executable/file, not the relative path.
If you want to use relative paths, use
start "" "%windir%explorer.exe" "relativefile.pdf","C:dir"
Security related
Using start "" "somefile.dat"
will try to execute the file as binary file and start it, if possible. This can end in security related issues.
You can test it by creating a copy of cmd.exe
calling it dummy.dat
and start it using start dummy.dat
answered Sep 14, 2021 at 11:36
ChristopherChristopher
2,8591 gold badge11 silver badges26 bronze badges
1-Open you folder that contains your application in the File Explorer.
2-Press SHIFT and Right Click in White Space.
3-Click on «Open command window here».
4-Run your application. (you can type some of the first characters of application name and press Up Arrow Key OR Down Arrow Key)
answered Jun 26, 2018 at 15:23
Contents
- 1 Windows Command Line
- 2 Navigating Windows Command Line
- 3 Windows Command Line Commands
- 4 Piping Commands
- 5 Output to a text file
- 6 Chaining Commands
- 7 Processes and Performance
- 8 Controlling Windows Services in Command Line
- 9 Windows Hard Disk Utils
- 10 User Control
- 11 Managing TCP/IP and Networking with WCL
- 12 More Resources:
Windows Command Line
A simple guide for any skill level.
Windows Command Line, known as a Command Line Interface, can be a very powerful tool for system administrators, power users, and technical support personnel. While most users will never see Windows Command Line, this guide is intended for Intermediate to Advanced users.
Most of Windows Command Line functions can be accessed through Windows GUI, other functions and programs can not. Knowing and understanding Windows Command Line will allow you to complete tasks faster, access features and programs not available in the Windows GUI, and look like you know what you’re doing.
Through this guide, we will walk through each section of commands that Windows XP Command line offers you the capability of. At the end, we discuss how scripting, and batch files can automate tasks, and save you time.
Terms:
CLI — Command Line Interface (non-GUI)
WCL — Windows Command Line
GUI — Graphical User Interface
Script — Chain of commands to be automatically run in order
Navigating Windows Command Line
To open Windows Command Line, click Start > Run and enter the word «cmd». This is a shortcut to opening a historic file called command.com, which is now called cmd.exe (the main program running WCL). The files for WCL can be found in «%systemroot%system32». Whenever you see a value starting and ending with %, you will know this is a variable. The %systemroot% variable will have a value of whatever your main windows folder is. For Windows XP, your system root is C:Windows, unless specified otherwise. For Windows 2000, your system root is C:Winnt.
Terms:
Variable — A value that can change based on user input
Syntax — The way a command is typed (word order)
Navigating the Command Line Interface: Commands and Examples
Each command in Windows Command Line has a different function. Each command also has a help document associated with it (for the most part). To access help for any command, try these two methods:
Windows Command Line Help
(command) /? — This /? at the end of the command will bring up a help document describing different «modifiers» you can add to command using the / symbol.
If you dont get a help document from the first command, check your syntax, and try the other help command.
HELP — Help document for WCL
Usage: help OR help <command>
Example: help
Example: help copy
Explanation: Help lists commands, help <command> shows command help document
Windows Command Line Commands
Listed below are some commonly used Windows Command Line Commands. They show the command name, its description, usage, and an explanation of what the example command would do.
CD — Change current working directory
Usage: cd <directory you want to open> OR cd
Example: cd
Explanation: Changes your working directory to root (c:)
Example: cd windows
Explanation: Takes you to the windows directory inside your current directory
COPY — copies files or folders to other locations that already exist
Usage: copy <file or folder from> <copy file or folder to>
Example: copy employees.txt c:workemployees
CLS — Clears the screen of all commands
Usage: cls
Example: cls
DEL — Deletes a file from current directory
Usage: del <folder or file name>
Example: del programs
Explanation: Deletes the folder or file named programs
DIR — Used to list all files in current directory
Usage: dir (modifiers can be listed with /?)
Example: dir
Explanation: This will list all files and folders at current location
EXIT — Exits CMD
Usage: exit
FIND — Finds a command given certain search parameters
Usage: Find <search term>
Example: Find «*.txt»
Explanation: Finds all text files in directory
Notes: * can be used as a ‘wildcard’ to mean any length or any combination of letters.
MD — Make directory at current location
Usage: md <directory name you want to make>
Example: md programs
Explanation: This will make a new folder at the current location
MOVE — Moves a file from one location to another (cut)
Usage: Move <full path of file you want to move> <already existing directory to move TO>
Example: Move c:gamesmygame.zip c:newgames
Explanation: This will move the file mygame.zip from one directory, to another existing directory
PAUSE — Pauses scripts or batch files and waits for user input
example: pause
Explanation: When in a script, this displays «Press any key to continue» and waits for user input
RD — Remove Directory
Usage — rd <folder name>
Example: rd windows
Explanation: This removes the directory Windows (bad idea)
Notes: to remove a directory and its contents, «rd /s windows»
REN — Rename a folder or file
Usage: ren <file or folder> <new name you want>
Example: ren windows window
Explanation: this changes your windows directory name to window
TIME — Check or modify system time
Usage: time
VER — Check your version of Windows
Usage: ver
Windows Command Line also interfaces with files on your computer to record data to. Piping and chaining commands is another option in most CLI situations. Chaining commands is simply feeding the output of one command (dir for example outputs a list of files and folders) to another command that you want to run only for the output of the first file.
Piping Commands
The chaining of commands can be used by typing | (shift + ). This is called the pipe, or piping commands. To pipe one command to another, type one full command, and WCL automatically outputs the data that you normally see to the next command.
For example, «dir c:windows | Find «*.txt»
The above example would list all files in c:windows then put all of the files and folders in c:windows get sent to the find command. The find command then looks for any files that end in .txt. You will now see a list of all txt files in c:windows
Output to a text file
Another useful function for script makers is the ability to output text from the command line (input and output) to a text document. Using the output to text file, or append options both come in handy at different times.
> — Create a new text file and have WCL output info to it
Usage: <command to output> > <location of text file to output to>
Example: dir > c:myfiles.txt
Explanation: This command would list all files and folders in current directory, and outputs to file c:myfiles.txt
>> — Append information from a command to a text document.
Usage: <command> >> <file to add to>
Example: dir > c:myfiles.txt
Explanation: This would list files and folders in current directory and ADD the list to myfiles.txt while keeping the previous data in tact.
Chaining Commands
When there are multiple commands you want to run at one time, Chaining commands in Windows Command Line comes in handy. To chain a command, we have two tools.
& — Complete one command then another directly after
Usage: command & command2
Example: dir & ver
Explanation: This will list all files in current directory and then the version of Windows Command Line
&& — Complete one command, then another if the first was successful
Usage: <command1> && <command2>
Example: copy c:importantdata.txt c:backup && ren backupdata.txt
Explanation: This will copy the file importantdata.txt to c:backup, THEN if successful, it will rename the file to backupdata.txt
Processes and Performance
Windows has its GUI version of system performance monitor that shows up every time you press CTRL-ALT-DELETE at the same time. There is also a command line version that can be configured to show much more information for power users.
Another thing to take into account is that when you open a CMD window, it will use a LOT less system resources than a GUI. This can be VERY helpful in ending processes that are lagging your computer a lot.
To access the process and performance monitoring tools, use the following commands:
Tasklist in Windows Command Line (DOS)
TASKLIST — Lists all running processes with detailed information
Usage: Tasklist
Note: the /svc addition to tasklist allows you to see what processes are using what services at the moment
Note2: /M addition shows each process, and associated DLL files
TASKKILL — Stops tasks with given parameters
Usage: Taskkill <which task>
Example: Taskkill /pid 140
Explanation: This will end the task with PID of 140 (the process identification number). You can find the PID for each task using tasklist
Controlling Windows Services in Command Line
Services are extra functions that Windows has the ability to start and stop depending on whether you allow the services to be started. A lot of windows services contribute to slow computing, security risks, and instability in the operating system. While some services are essential, others are never needed. Windows XP Services
To list, modify, start and stop services you will need a new commands to help you.
SC query — Shows list of configured services
Usage: SC query
Explanation: This will list info and data on services
SC qc — Queries a specific service
Usage: SC qc <service name>
Example: sc qc messenger
Explanation: This will show configuration data for the messenger service
SC start — Starts a specific service
Usage: SC start <service name>
Example: SC start messenger
Explanation: This starts the messenger service
SC stop — Stops a specific service
Usage: SC stop <service name>
Example: SC stop messenger
Explanation: This stops the messenger service
SC config — Configures service properties
Usage: SC config <service name> start= <start type>
Example: SC config messenger start = disabled
Explanation: This will tell the messenger service NOT to start with the computer.
Notes: Settings available for start= are Disabled, Auto, and Demand
Disabled never starts, Auto starts every startup, and demand starts as the service is needed
Windows Hard Disk Utils
Windows comes with extensive command line utilities to control, check and maintain your hard disk drives. Included in the utilities are Drive Partitioners, Defragmenters, Check Disk Utilities, and utilities to set a drive to be checked for errors on next startup.
Try some of these Windows Command Line Commands, as they can save your computer in case of disasters like virus’s or improper shutdowns.
CHKDSK — Checks a hard disk for errors
Usage: chkdsk <parameters> <drive to check>
Example: chkdsk /f C:
Explanation: This command will scan drive C for errors, and repair them if needed.
Notes: /f parameter auto-repairs errors when found
DEFRAG — Defragments a hard drive to optimize performance
Usage: Defrag <parameter> <drive letter>
Example: Defrag c:
Explanation: Desfragments the C: drive
Notes: defrag -a <drive letter> will analyze only, and not defragment
User Control
Embedded in Windows XP is the ability to add and remove users. This concept is called a «Multi-User Operating System». This type of system allows for more than one user account to be made, each account with specific permissions to access data or run programs. User Accounts can be changed from control panel, or Windows Command Line.
NET USER — View a list of local user accounts
Usage: Net User <name of user, or blank for all>
Example: Net User Chris
Explanation: Displays user account info for user Chris
Notes: Access to net user can be used across a single domain also
Parameters: net user <name> /delete
Explanation: This deletes a user account
NET USER — Adds users to local computer
Usage: net user <username to add> <password to add> /add
Example: net user chris library /add
Explanation: This will add a user to the local computer with the name as chris, and the password as library
Notes: Parameters that go BEFORE /add are
/fullname:»Chris Reed» (Full name of user)
/comment:»Chris is main systems admin» (users comments)
/passwordreq yes (requires password at logon)
Example 2: net user Chris library /fullname:»Chris Reed» /comment: «Chris is main systems admin» /passwordreq yes /add
Explanation: This adds user Chris with password library, and full user name of chris reed, with a user comment as «Chris is main systems admin» and requires a password at logon
Managing TCP/IP and Networking with WCL
TCP/IP is a transmission protocol for two computers communicating through a network. TCP/IP has error checking for the packets that are transferred, and is used in many internet and networking situations.
Windows Command Line allows you to view detailed information about your internet connection, DNS servers, DHCP servers, your internal IP address, and defualt gateway. The commands below will show you how to check your TCP/IP status, modify servers, and set static IP addresses.
Terms:
[code]DHCP — Automatically determined IP set for your computer
Static IP — A custom setup network configuration with unchanging IP
TCP/IP — Communication protocol for 2 computers over a network
Default Gateway — Your router or gateways IP address
Subnet Mask — Defines the section of a network you are on
DNS servers — Computer that resolves URL to IP (www.yoursite.com to IP)
IP address — Your individual computers network ID
Note: To check your TCP/IP connections, network adapter, and settings, you can type ping «127.0.0.1». This will send a ping out through your network adapter, and redirect it right back to your computer. Upon successful ping, you can tell that your computer is setup properly to use TCP/IP.
==
TCP/IP from Windows Command Line ==
IPCONFIG — Shows IP information for your computer
Usage: IPCONFIG or IPCONFIG /all
Example: ipconfig /all
Explanation: Shows all information about current TCP/IP connection
Notes: Other parameters /flushDNS (resets DNS cache) /release (releases your network adapter) /renew (renews your network adapter)
SET ADDRESS — sets tcp/ip settings via WCL
Usage: Set address name=»<connection name>» source=<static or dhcp> addr=<static IP> mask=<subnet mask> gateway=<gateway IP>
Static IP Network Configuration
Example: Set address name=»Local Area Connection» source=static addr=192.168.1.201 mask=255.255.255.0 gateway=192.168.1.1
Explanation: This will make the computer setup a new connection called Local Area Connection, with a STATIC IP of 192.168.1.201, a subnet mask of 255.255.255.0 and a gateway of 192.168.1.1
DHCP Network Configuration
Example: set address name=»Local Area Connection» source=»dhcp»
Explanation: This will setup a new connection name Local Area Connection that will try to automatically set your IP using DHCP protocol. (Your router or gateway will be the DHCP server usually)
DELETE ADDRESS — Removes a connection from your list
Usage: Delete Address name=<address name> addr=<IP address>
DNS Server Setup
DNS servers are computers connected to the internet with records of URLs (www.yoursite.com) and the matching IP address for the URLs server (68.48.0.12). Your computer connects to a DNS server every time you enter a web page in your address bar. Although you dont usually see the IP address information, it is hiding beneath your browser or internet program.
To setup custom DNS servers using WCL, you will need the following commands. For your DNS server, you can either contact your ISP, and use one of theirs, or you can try using your router.
ADD DNS — Sets custom DNS servers to use
Usage: ADD DNS name=<DNS server name> addr=<ip of DNS server>
Example: ADD dns name=»My Pinacolataburg DNS» addr=»68.48.0.12″
Explanation: Adds a DNS server named My Pinacolataburg DNS with an IP address of 68.48.0.12
DELETE DNS — removes a specific DNS entry from a connection
Usage: delete dns name=<name to delete> addr=<IP to delete>
Example: delete dns name=»My Pinacolataburg dns» addr=68.48.0.12
Explanation: This will remove the DNS server entry above
Windows Command Line has an array of tools for diagnosing network problems. You can view individual stats for network adapters and network connections. You can also view the path to a certain internet host, get ping information for the host, and find all open TCP/IP connections with information on what program is using the connection.
Tracert — Find ping, and number of hops to reach a given server
Usage: Tracert <internet host to trace the route to>
Example: tracert www.computershack.net
Explanation: This command would give tracert information from the originating computer, to the opposite end of the connection.
PING — Find how long it takes for a message to be send to a server, and back again.
Usage: Ping < internet host IP or URL >
Example: ping www.computershack.net
Explanation: Ping shows the time, in milliseconds it takes to contact the given IP or URL, plus the time it takes to get back to your computer.
NETSTAT — Shows information about network connections
Usage: Netstat <parameters>
Example: Netstat -b
Explanation: With the parameter -b, netstat shows a list of all open connections, the port, and program that is managing the connection.
Notes: Another parameter is -a to view all open connections/ports
NETSH — Network Shell is a collection of tools to diagnose network components.
Usage: NETSH <parameter>
Example: NETSH diag ping adapter
Explanation: This will ping each item in your TCP/IP configuration. Included is DNS, DHCP, WINS, and Default Gateway
Conclusion: Using the information in this document, it is possible to control, maintain, diagnose, and fix problems in almost all categories. With this information, try using Windows Command Line more often. It will help you become a better technician, and be able to fix more problems faster.
More Resources:
- Official Microsoft Command Line Reference
-
MiniTool
-
MiniTool News Center
- How to Run Program from CMD (Command Prompt) Windows 10
By Alisa | Follow |
Last Updated September 01, 2022
You can run a program or an exe file from Command Prompt. Check how to do it in this tutorial. MiniTool software, not only provides many useful computer solutions, but also provides users many useful computer software like data recovery program, disk partition manager, system backup and restore software, video editor, etc.
If you want to run program from CMD (Command Prompt) on Windows 10, you can check the detailed steps below.
How to Run a Program from CMD in Windows 10
You can only run the applications that are installed in Windows-created folders like Explorer in Command Prompt.
Step 1. Open Command Prompt in Windows 10
At first, you should open Command Prompt application on your Windows 10 computer. You can press Windows + R, type cmd, and press Enter to open normal Command Prompt or press Ctrl + Shift + Enter to open elevated Command Prompt on Windows 10.
Step 2. Run Program from CMD on Windows 10
Next you can type start <program name> command in Command Prompt window, and press Enter to open the target application in CMD. Replace the “program name” with the exact file’s system name of the program but not its shortcut name. For instance: start explorer.
The file’s system name of some common programs in Windows are as follows:
- Command Prompt: cmd
- File Explorer: explorer
- Task Manager: taskmgr
- Calculator: calc
- Notepad: notepad
- Paint: mspaint
- Windows Media Player: wmplayer
How to Run EXE in CMD on Windows 10
You can follow the instructions below to run an exe file in Command Prompt.
Step 1. Access Command Prompt window
You can follow the same operation above to open Command Prompt in Windows 10.
Step 2. Navigate to the folder of the target program
Next you can type cd <file path> command in Command Prompt window, and press Enter to navigate to the folder that contains the target exe application. Replace “file path” with the exact file path of the exe file.
You can find the target program folder and click the address bar at the top of File Explorer window to copy the path of the program folder and paste it after cd command. For example, cd C:Program FilesWindows Media Player.
Step 3. Run exe from CMD
After you are in the target program folder path, then you can type start <filename.exe> after the selected file path in CMD, and press Enter to run the exe file in Command Prompt. Replace “filename.exe” with the target program name, e.g. start wmplayer.exe.
Bottom Line
This post introduces how to run a program or exe file from CMD on Windows 10. Hope it helps.
If you need a free data recovery software to recover deleted/lost files from Windows 10 computer or other storage devices, you can try MiniTool Power Data Recovery.
MiniTool Power Data Recovery is a Windows data recovery program that allows you to recover data from PC, external hard drive HDD or SSD, USB drive, SD card, memory card, and more. It is very simple to use and 100% clean.
About The Author
Position: Columnist
Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.
Содержание
- How do you run a command as an administrator from the Windows command line?
- 9 Answers 9
- Caveat: Enable the admin account
- CommandWindows.com
- Introduction to the Run Line
- Opening applications in Run
- Opening Management Consoles
- Opening Control Panel Applets
- Rundll32.exe
- Opening folders in Run
- Dragging and dropping folders and files into the Run line
- Adding applications to the Path
- Internet Applications
- Comparison of Run with the Command Prompt
- Accessing the Command Shell from Run
- The Run Line in Windows Vista or Windows 7
How do you run a command as an administrator from the Windows command line?
I have a small script that performs the build and install process on Windows for a Bazaar repository I’m managing. I’m trying to run the script with elevated, administrative privileges from within the Windows shell (cmd.exe)—just as if I’d right-clicked it and chosen Run as Administrator, but without using any method that requires use of the graphical interface.
9 Answers 9
Press the start button. In the search box type «cmd», then press Ctrl + Shift + Enter
All you have to do is use the runas command to run your program as Administrator (with a caveat).
In my case, this was
Note that you must use Quotation marks, else the runas command will gobble up the switch option to cmd.
Also note that the administrative shell (cmd.exe) starts up in the C:WindowsSystem32 folder. This isn’t what I wanted, but it was easy enough to pass in the current path to my installer, and to reference it using an absolute path.
Caveat: Enable the admin account
Using runas this way requires the administrative account to be enabled, which is not the default on Windows 7 or Vista. However, here is a great tutorial on how to enable it, in three different ways:
I myself enabled it by opening Administrative Tools, Local Security Policy, then navigating to Local PoliciesSecurity Options and changing the value of the Accounts: Administrative Account Status policy to Enabled, which is none of the three ways shown in the link.
Источник
CommandWindows.com
Introduction to the Run Line
The Run command line may be one of the least utilized functions in the Start menu. This is a pity since it can be very useful. It is often the quickest way to launch programs or to open folders and documents. The figure below shows the Start-Run entry for Windows XP. Windows Vista/7 do not display the Run line on the Start menu in the default setting but the Run line can be accessed in all current versiions of Windows by pressing the keyboard combination Windows key + R. Adding the Run line to the Windows Vista/7 Start menu is discussed at the end of this article.
Clicking the entry «Run» opens the box shown below, where commands may be typed and entered.
Opening applications in Run
Although applications can be opened in a variety of ways, the Run line often provides the quickest route. Desktop shortcut icons are also a quick route but you have to know how to create a shortcut for all the applications and you may end up with dozens of icons.
A table listing some applications that can be opened in the Run line is given below.
Entry for Run | Function |
---|---|
calc | Opens calculator |
cmd | Opens command prompt window |
explorer | Opens Windows explorer |
magnify | Screen magnifier accessory |
msconfig | System Configuration Utility |
mshearts | Opens Hearts game |
msinfo32 | System Information applet |
mspaint | Opens graphics accessory Paint |
notepad | Notepad accessory |
regedit | Registry editor |
sol | Opens Classical Solitaire game |
Programs not in the path require their full address, including the root folder and all subfolders. Actually typing long path names is not required since a «Browse» function comes with the Run line. This provides a way to search for files of interest and to enter them directly without typing. If desired, frequently used programs can be added to the path environment using the methods that are discussed in a section below.
Opening Management Consoles
Entry for Run | Function |
---|---|
ciadv.msc | Manages the Indexing Service |
compmgmt.msc | Computer Management Console. It contains a number of the other consoles |
devmgmt.msc | Device Manager |
dfrg.msc | Disk Defragmenter |
diskmgmt.msc | Disk Management |
gpedit.msc | Group Policy Editor. Not available in Windows Home editions |
services.msc | Manages the many services involved in Windows and installed software |
Opening Control Panel Applets
It is also possible to use Run to open the applets that appear in the Control Panel. A full discussion of shortcuts to Control Panel applets is given on this page. For example,entering «main.cpl» launches the mouse properties window.
Rundll32.exe
There are a number of commands employing Rundll32.exe that can be entered into Start-Run. A full discussion can be found here.
Opening folders in Run
Not only files but also folders can be opened in the Run line. Folders contained by a folder in the path are in this category. Examples are folders within Windows and Windowssystem32 such as the folders Fonts and «Drivers». Folders that are in Documents and Settings\ can also be opened in Run. An example is SendTo (written as one word). Being able to open this folder in Run is convenient for editing. It makes it easier to add functions to the «Send To» entry in the right-click context menu. (See this page) Another example of a folder from the same location that can be entered is Cookies.
Note about Vista: Certain system folders like SendTo and Cookies are not directly accessible in Vista. See the page on the Shell command.
There are also some interesting shortcuts to folders that are available in Run. Typing the backslash () in the run line and entering it brings up the root folder, usually the C: drive. Typing and entering a period (.) brings up the folder Documents and Settings\ in Windows XP (or Users(Current User> in Vista). Entering two periods (..) opens the folder Documents and Settings (or Users in Vista).
Dragging and dropping folders and files into the Run line
If the Run line is open (make sure it is empty) folders or files can be dragged and dropped on it from an open folder window. The full path of the dropped object will be inserted into the Run line and clicking «OK’ or pressing the «Enter» key will open the dropped file or folder. Although this feature presents no particular advantage in general, it can be helpful to those who have trouble with double-clicking the mouse.
Adding applications to the Path
The ability to enter a short file name into the Run line to open a program can be extended to any program by putting the folder containing the program executable into the path. Adding folders to the path is described here.
Alternatively, the Registry can be edited to explicitly contain the path to the desired executable file or files. The Registry key involved is HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionApp Paths
A number of files are likely to have already been added on your system. Many applications place themselves here when they are installed. Examples are Microsoft Office components. It is sufficient to enter «winword» into the Run line to open Microsoft Word or «excel» to open Microsoft Excel.
Internet Applications
If you are connected to the Internet, entering an URL into Run opens Internet Explorer (or other browser if it is properly associated) and takes you right to the appropriate web site. The «Browse» function can be used to go to your Favorites folder and you can then click on a link. (Be sure the Browse function is showing «All files» as the file type.) On some systems it will even initiate a Web connection if you are not already on-line. You can also start e-mail by entering “mailto:someone@somewhere.com”. This will open a blank new e-mail with the address already entered. If you want to use an e-mail client other than the Microsoft application Outlook Express, it will have to be associated with the “mailto” function. Many e-mail clients do this automatically when they are installed. (As far as I know, this does not apply to AOL.)
Google supports a command line function that allows for simple searches on on a single term. Enter «www.google.com/search?q=%1» into the Run line, where %1 is the term that is being searched. A dash can be used to combine words. For example, try «www.google.com/search?q=windows-registry» (Omit the quotes.)
Comparison of Run with the Command Prompt
Although a great many commands can be executed in either the Run line or a command prompt, some commands will run directly only in one or the other. Commands which are built into the command interpreter cannot be entered in the Run line without first invoking cmd.exe. They are listed here. These include commands like «dir» and «del». Certain special features of the Run line such as the direct way of opening folders or the Internet shortcuts discussed above do not work in a command prompt unless prefaced with the command «Start».
Accessing the Command Shell from Run
The command interpreter can be invoked to carry out a command from the Run line by entering cmd /c some_command With the switch «/c», some_command will be carried out and the command shell will then close. If you want the command shell to remain open, use the switch «/k». Enter cmd /k some_command
The Run Line in Windows Vista or Windows 7
The Start menu in Vista has no Run line in its default setting. Many of the functions of Run can be carried out in the new Search function that is at the bottom of the Vista Start menu but I still like to use Run sometimes. You can get Run back temporarily by using the keyboard shortcut Windows key+R. To put Run permanently back in the Start menu :
Источник