Skip to content

/errors/cmd/the-system-cannot-find-the-file-specified

cmd: The system cannot find the file specified.

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Command Prompt (cmd)
exit code
1
versions
Windows 10, Windows 11, Windows Server 2016+
os
windows

The system cannot find the file specified. is Windows system error 2 (ERROR_FILE_NOT_FOUND): the folder part of the path exists, but there is no file with that name in it. If a folder in the path is missing, cmd prints The system cannot find the path specified (error 3) instead. Run dir /b in the folder and compare the real name, including its extension.

Reproduce it

cmd
type notes.txt 2>&1
echo type: ERRORLEVEL=%ERRORLEVEL%
copy notes.txt backup.txt 2>&1
echo copy: ERRORLEVEL=%ERRORLEVEL%
> "notes.txt.txt" echo hidden extension
dir /b *.txt
type "notes.txt.txt"

Output

The system cannot find the file specified.
type: ERRORLEVEL=1
The system cannot find the file specified.
copy: ERRORLEVEL=1
notes.txt.txt
hidden extension

The last lines show a common cause: in Explorer with "File name extensions" off, notes.txt.txt is displayed as notes.txt.

Fixes

  1. Check the real name: dir /b, or dir /b *notes* when unsure. Turn on View > Show > File name extensions in Explorer.
  2. Check the current folder: cd without arguments prints it. Batch files started from Explorer or Task Scheduler do not start in the script's folder; use cd /d "%~dp0" or full paths built on %~dp0.
  3. Quote paths with spaces: type "C:\My Files\notes.txt".
  4. Programs started with start, services and scheduled tasks show this error as a dialog or in their logs when the executable path is wrong. Check the path in the task or service definition.

Sources