Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 692
user3848207 Avatar asked Jul 27 '20 08:07

user3848207


People also ask

How do I find my system path?

Select Start, select Control Panel. double click System, and select the Advanced tab. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it.

What does it mean when it says the system Cannot find the path specified?

If it throws "The system cannot find the path specified." error again means you have some more invalid paths in PATH environment variable. Just keep correcting or removing them until your PATH is printed completely by echo %PATH%.

How do I fix the system Cannot find the specified?

Use SFC to fix system cannot finds the file specified error. In Command Prompt, type the following command: “sfc /scannow”. Now press Enter. After scanning and correcting errors, restart the computer and check if the “system cannot find the file specified” error is fixed.


Video Answer


1 Answers

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.

like image 135
factorypolaris Avatar answered Oct 16 '22 11:10

factorypolaris