How to fix `The system cannot find the path specified` error on Windows 10?

15,868

Powershell Path Test

Here is a one line Powershell script that will test all paths in your PATH Environment Variable exist. It will report OK or MISSING for each path. If any paths are listed as missing, you should manually remove them from the Environment Variable.

@($env:path -split ";").ForEach({ if($_) {$result = 'MISSING |';if(Test-Path -path $_) { $result = '     OK |'};-join($result, ' ', $_); }})

Option 2

Run the following from an Elevated CMD prompt. This ensures all windows paths and executables are available, permissions correct and non corrupt. After running it, it will give further instructions if needed.

sfc /scannow

About sfc /scannow


Option 3

Open the Registry Editor (regedit.exe). Check the following (if the exist) for invalid not wanted paths. As Usual, BACKUP Registry Before Making Changes.

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun

Option 4

Get the small utility Process Monitor from Microsoft's site. Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. You WILL find the offending path using this tool.

  1. Download, Extract & Run
  2. Close as many open programs as possible.
  3. In Process Monitor, under file is a capture events checkbox to enable/disable. Once you get it open, stop capturing, then choose Edit -> Clear Display.
  4. Now get ready to reproduce the "System cannot find the path specified" error.
  5. Just before triggering the error, enable "Capture Events". Upon the error, immediately disable "Capture Events" in Process Monitor.
  6. Use the "Filter" menu to find the offending operation. Find rows with a Result of "NAME NOT FOUND" or "PATH NOT FOUND". The offender will likely have an "Event Class" = "File System" || "Registry". It may be another Result/Event Class but, I would start there.

Some Filters to try and narrow down the offender:

  • "Result" -> NOT -> "SUCCESS"
  • "Process Name" -> IS -> "cmd.exe" (or other shell)

After you find what you're looking for, and fix the issue, you will at minimum need to close and re-open your prompt before re-testing, but may also need to perform a reboot.

If removal of the offending record can be uninstalled vs just removed, do this as a bad/outdated Filesystem path may only be half the issue, additionally requiring a registry record update. The uninstaller should solve both.

If changes to to your Registry are needed, Ensure you first create a backup using regedit.exe.

Share:
15,868
user3848207
Author by

user3848207

Updated on July 29, 2022

Comments

  • user3848207
    user3848207 over 1 year

    I am using Windows 10.

    I keep encountering the error message The system cannot find the path specified whenever I run a python script, start a cygwin terminal, bash script ...

    There is no meaningful error message to pinpoint the exact cause. I suspect this is due to one of the pathnames in PATH variable to be pointing to non-existent path. How can I find out which pathname is causing it?

    If someone can point me to other possible causes, please share.

    Thank you.

  • user3848207
    user3848207 over 3 years
    Thanks for the answer! I have tried the 2 methods. They look promising but the problem persists. The sfc results were Windows Resource Protection found corrupt files and successfully repaired them. This issue doesn't cause me any problems so far but it's an eye-sore to see this cannot find specified path error pop up now and then. The first method tells me the problem is probably not caused by invalid PATH variable. What are some possibilities that can still cause this cannot find specified path error?
  • factorypolaris
    factorypolaris over 3 years
    See updates. Options 3 and 4. I'm confident one of them will get this taken care of.
  • ElderDelp
    ElderDelp over 3 years
    Of the four options, 3 can be run as a regular user! Only #2 takes admin rights. #3 worked for me, an anaconda uninstaller left some cruft behind in HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
  • wtfzambo
    wtfzambo about 3 years
    Thanks, to me the problem was caused by "option 3", due to an old installation of Anaconda. When I installed a new one after removing the old one, probably the registry key didn't get fixed in the process.