Error Messages and Fixes
Table of Contents
Command Prompt error messages are short and often do not say what is actually wrong. The same message can have several different causes, such as a typo, missing permissions or a space in a path.
This page explains what the common error messages mean, how to narrow down the cause, and how to fix each one.
Paste an error message to find the cause
Paste the message as it appears, and the tool shows which error it is and what to try first. You can paste several lines at once.
Paste the message shown in Command Prompt, in full or in part.
The check runs on this page. What you paste is not sent anywhere.
Paste an error message and the cause and fix appear here.
Quick reference: common error messages
| Error message | Common causes | What to try first |
|---|---|---|
| ’…’ is not recognized as an internal or external command, operable program or batch file. | Typo, not installed, not on PATH, space in a path | Check with where name |
| Access is denied. | Needs administrator rights, read-only file, no permission | Run as administrator, attrib -r |
| The requested operation requires elevation. | Not running as administrator | Reopen as administrator |
| The system cannot find the path specified. | Folder does not exist, wrong current folder | Check with cd, use cd /d "%~dp0" |
| The system cannot find the file specified. | Wrong name or extension, wrong location | Check real names with dir /a /b |
| The filename, directory name, or volume label syntax is incorrect. | Characters not allowed in names (: / ? etc.) | Remove : and / from %time% / %date% |
| The syntax of the command is incorrect. | Wrong options, unbalanced parentheses | Check with command /? |
| … was unexpected at this time. | Empty variable, ) inside a block, %i in a batch file | Quote variables, use %%i |
| The process cannot access the file because it is being used by another process. | Another app has the file open | Close it, find it with resmon |
| The directory is not empty. | rmdir on a folder with contents | rmdir /s /q |
| A subdirectory or file … already exists. | The folder already exists | Check with if not exist first |
| A duplicate file name exists, or the file cannot be found. | The new name for ren is taken | Check names with dir |
| The system cannot find the drive specified. | Drive not connected | Check with net use |
| The input line is too long. | A line exceeded 8191 characters | Stop appending to PATH repeatedly |
Causes and fixes by error message
“is not recognized as an internal or external command”
This is the most common error. It means the command or program name you typed could not be found.
Command Prompt looks for the name in this order, and shows this error when it is found nowhere:
- Built-in commands such as
dirandcopy - The current folder
- The folders listed in the
PATHenvironment variable (trying extensions such as.exe,.batand.cmd)
First, use where to check whether the command exists anywhere.
where python
echo %PATH%
If where finds nothing, or finds it but it still will not run, use this table to narrow down the cause.
| Situation | Example | Fix |
|---|---|---|
| Typo | ipconfg | Retype the name correctly |
| A path with spaces is not quoted | 'C:\Program' is not recognized… | Quote the whole path, like "C:\Program Files\app\app.exe" |
| The software is not installed or not on PATH | python git node java | Install it and add it to PATH (environment variables and PATH) |
| The window was opened before PATH changed | Right after installing | Open a new Command Prompt |
| You typed a Linux or macOS command | ls cat grep | Use the commands in the table below |
| A Windows feature is disabled or removed | telnet wmic | Enable the feature or use a replacement |
& or ` | ` was treated as a separator | echo A & B gives 'B' is not recognized |
| Only the first line of a batch file fails | '@echo' with odd characters in front | Save it again without a BOM (see below) |
A batch file saved as “UTF-8 with BOM” starts with an invisible character called a BOM. Command Prompt reads it as part of the command name, so @echo off on the first line fails with an error like '∩╗┐@echo' is not recognized…. Save the file again as “UTF-8” (without BOM) or “ANSI”. See fixing garbled text for choosing an encoding.
Linux / macOS commands and their Command Prompt equivalents
| You typed | In Command Prompt, use |
|---|---|
ls | dir |
cat | type |
grep | findstr |
rm / rm -r | del / rmdir /s |
cp | copy (robocopy for whole folders) |
mv | move |
touch file | type nul >> file |
clear | cls |
pwd | cd |
which | where |
ps / kill | tasklist / taskkill |
ifconfig | ipconfig |
man command | command /? |
sudo | Run Command Prompt as administrator |
On Windows 11 version 24H2 and later, sudo can be turned on in Settings → System → For developers.
Commonly reported command names
| Command | Cause and fix |
|---|---|
python / pip | “Add python.exe to PATH” was not checked during installation. If Python is installed, py (the Python launcher) and py -m pip usually work |
git | Git for Windows is not installed. Install it with winget install --id Git.Git -e and open a new window |
node / npm | Node.js is not installed, or the window was opened before installing it |
java / javac | No JDK is installed, or the JDK bin folder is not on PATH |
code | “Add to PATH” was not enabled when installing VS Code |
winget | “App Installer” from the Microsoft Store is outdated. Update it in the Store |
wmic | A tool being phased out; newer versions of Windows 11 may not include it by default. Replace it with PowerShell’s Get-CimInstance |
telnet | The Telnet Client is disabled. Enable it as administrator with dism /online /Enable-Feature /FeatureName:TelnetClient |
“Access is denied”
You do not have permission for the operation. There are three main causes.
| Cause | Typical situation | Fix |
|---|---|---|
| Administrator rights are required | Changing files in C:\Windows or C:\Program Files, managing services, net commands | Run as administrator |
| Read-only or system attribute | del cannot delete a file | Remove the attribute with attrib -r file, or use del /f |
| No NTFS permission | Another user’s folder, files copied from elsewhere | Check permissions with icacls |
attrib "C:\work\report.txt"
attrib -r "C:\work\report.txt"
icacls "C:\work\report.txt"
If attrib shows R (read-only), remove it with attrib -r. net commands show “System error 5 has occurred.” along with this message; it means the same thing and is usually solved by running as administrator.
“The requested operation requires elevation”
This appears when you start a program that only runs as administrator from a regular Command Prompt. The sfc message “You must be an administrator running a console session in order to use the sfc utility.” has the same cause.
You can check whether the current window is running as administrator with the following command (it relies on net session failing for non-administrators).
net session >nul 2>&1 && echo Admin || echo Standard user
If it shows “Standard user”, reopen Command Prompt as administrator. To make a batch file relaunch itself as administrator, see auto-elevating batch files.
“The system cannot find the path specified”
The folder you specified, or a folder along the way, does not exist. Besides typos, these three causes are common:
- The current folder is not what you expect: relative paths (such as
data\input.txt) start from the current folder. In particular, running a batch file as administrator makes the current folderC:\Windows\System32, so files next to the batch file are no longer found. - The destination folder does not exist:
copyandmovedo not create a missing destination folder. Create it first withmkdir. - A network drive is not visible: network drives mapped as a regular user may not be visible from a Command Prompt running as administrator. Use a UNC path such as
\\server\shareinstead.
In a batch file, moving to its own folder first makes it behave the same wherever it is started from.
@echo off
cd /d "%~dp0"
%~dp0 is the path of the folder containing the batch file. See getting and changing the current directory for details.
“The system cannot find the file specified”
No file with that name exists. dir shows “File Not Found” and del shows “Could Not Find …” for the same situation.
- The extension is different: when Explorer hides extensions, a file you think is
memo.txtmay actually bememo.txt.txt. - Hidden files:
dirdoes not show hidden files by default. - You are looking in the wrong place: check the current folder (see the previous section).
dir /a /b
where /r . memo*.txt
dir /a /b lists names including hidden files, and where /r . searches the current folder and its subfolders.
“The network path was not found”
This appears with net use or when accessing \\server\share if the other computer cannot be reached (System error 53). Common causes are a wrong computer name, the computer being off, file sharing being disabled, or a firewall blocking the connection.
ping servername
net view \\servername
If ping fails, the problem is the network or name resolution. If ping works but net view fails, the problem is the file sharing settings.
“The filename, directory name, or volume label syntax is incorrect”
The file name or path contains a character that is not allowed (\ / : * ? " < > |). A common case is using %date% or %time% directly in a file name.
rem The ":" in 12:34:56.78 ends up in the file name and causes the error
echo test> log_%time%.txt
Remove : and / before using them.
set t=%time: =0%
set t=%t::=%
set d=%date:/=%
set d=%d: =%
echo test> "log_%d%_%t:~0,6%.txt"
%variable:old=new% replaces characters, and quoting the file name keeps any remaining spaces from splitting it. The format of %date% depends on the regional settings (in en-US it starts with the day of the week, as in Fri 11/20/2026), so see getting the date and time for a format-independent method. Mismatched quotes also cause this error.
“The syntax of the command is incorrect”
The options or arguments do not match the syntax of the command.
- Misspelled or misordered options → check the correct syntax with
command /?. - Unbalanced parentheses in
iforfor. - An empty variable leaves the command with too few arguments.
If you cannot tell which line of a batch file causes it, temporarily change @echo off at the top to rem @echo off and run it. Each line is shown as it runs, so the line shown just before the error is the likely cause.
”… was unexpected at this time”
While reading an if, a for or a parenthesized block, cmd met a character that cannot appear there. The text shown in the message is the clue.
| Message | Common cause | Fix |
|---|---|---|
i was unexpected at this time. | You wrote for %i inside a batch file | Use %%i in batch files (for command) |
==abc was unexpected at this time. | You compared an empty variable (if %var%==abc) | Quote both sides: if "%var%"=="abc" |
\Microsoft was unexpected at this time. | %PATH% was expanded inside a block, and the ) in (x86) closed the block | Quote the assignment: set "PATH=%PATH%;C:\tools" |
) was unexpected at this time. | An echo inside a block contains ) | Escape it as ^) |
If variables inside a block also do not change as expected, see delayed expansion.
“The process cannot access the file because it is being used by another process”
Another app or process has the file (or folder) open, so it cannot be deleted, moved or overwritten. Typical cases are a file open in Excel, the Explorer preview pane, or a folder that is the current folder of another Command Prompt.
If you do not know which process is using it, Resource Monitor can find it.
resmon
On the CPU tab, type the file name in the search box of “Associated Handles” to see which processes have it open.
“ERROR: The process ”…” not found”
taskkill /im shows this when no running process has the image name you gave. The image name is the executable file name including .exe, and it can differ from the window title or the app’s display name (for example, Edge is msedge.exe). Check the real name with tasklist first.
tasklist | findstr /i "edge"
taskkill /im msedge.exe
Trying to end a process that runs as administrator from a regular Command Prompt results in “Access is denied” instead.
“The directory is not empty”
rmdir (rd) does not delete a folder that still has contents. Add /s to delete it with everything inside.
rmdir /s /q "C:\work\old"
With /q, it is deleted without confirmation. It does not go to the Recycle Bin and cannot be undone, so double-check the path. If it still fails with /s, a file inside is being used by another process (see above).
“A subdirectory or file … already exists”
The folder you tried to create with mkdir (md), or a file with the same name, already exists. In a batch file, create it only when it does not exist.
if not exist "C:\work\logs\" mkdir "C:\work\logs"
Adding \ at the end of the path checks that it exists as a folder (checking whether files and folders exist).
“A duplicate file name exists, or the file cannot be found”
ren (rename) shows this when a file with the new name already exists or the original file is not found. Check both names with dir /b. ren cannot move files to another folder; use move for that.
“The system cannot find the batch label specified”
When the label in goto label or call :label is not found, the batch file stops with this error.
- The label name is misspelled (
:endandgoto edn, for example). - The batch file uses LF-only line endings. When Linux tools or Git settings convert line endings to LF, labels may not be found correctly. Save the file again with CRLF line endings.
You can list the labels in a file with line numbers:
findstr /n "^:" "build.bat"
“The system cannot find the drive specified”
This appears when you switch to a drive that does not exist, such as D:. Typical causes are an external drive that is not connected, or a disconnected network drive (which may also be invisible from a window running as administrator). If the drive letter exists but has no media, the message is “The device is not ready.” instead.
net use
net use shows the mapped network drives and their status.
“The input line is too long”
After variables were expanded, a line exceeded the Command Prompt limit of 8191 characters. This often happens when a batch file runs set PATH=%PATH%;... repeatedly and PATH keeps growing. With setlocal, changes made in the batch file are undone when it ends, so PATH does not keep growing (setlocal / endlocal).
“Environment variable … not defined”
This appears when you try to show a variable that does not exist with set name. It is less an error than a statement that the variable is not set. In a batch file, use if defined to check whether a variable exists.
if defined JAVA_HOME (echo JAVA_HOME is set) else (echo JAVA_HOME is not set)
The message is garbled
If the error message turns into � or random characters, the code page (the character encoding used for display) does not match.
Detect errors in a batch file
Apart from the message on screen, most commands report success or failure with an exit code (%errorlevel%). In a batch file, checking it is more reliable.
copy "a.txt" "backup\" >nul 2>&1 || echo Copy failed
2>&1 discards error messages (standard error) too, and || runs the next command only when the previous one failed.