"The system cannot find the path specified." at the beginning of cmd - cmd

I ran the command prompt with administrator privilege to uninstall Ananconda on my computer, after the process, I reopened the cmd and found this line, "The system cannot find the path specified" at the beginning of my cmd.
I can guarantee that my cmd did not have this line before, how can I manage to fix it? Is it a serious bug that I should be aware of?
Thank you.
"The system cannot find the path specified."

Open the Registry Editor (Windows key and type regedit in the prompt)
Go to HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun and clear the values.
If it exists in HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun, delete it as well.

Related

Batch file throws "The system cannot find the path specified" on a valid path

I am new to batch and while i made a script, the following error occurs: The system cannot find the path specified. Here is the code for the file:
title HelloBatch
cd C:/Users/"%USERNAME%"/Desktop
break > test.txt
I tried doing %USERNAME% without the quotatiion marks, NOPE, it still shows error.
Another note is that my username containe spaces. is that why it displays the error? if yes, how can i solve it?
What happen when you run cd C:/Users/"%USERNAME%" in command prompt? If it change directory correctly, try cd Desktop .
Windows can sometimes remap the Desktop to somewhere else. For example, OneDrive can make the Desktop C:\Users\%USERNAME%\OneDrive\Desktop . You can check the actual path from Explorer by opening any directory on the Desktop.
It should be "%USERNAME%" since when your username has spaces (example: "some username")
then if you use %USERNAME% it will think that your username is some and not some username. To fix that you need to add "%USERNAME%" with the quotation marks.

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?
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.
Download, Extract & Run
Close as many open programs as possible.
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.
Now get ready to reproduce the "System cannot find the path specified" error.
Just before triggering the error, enable "Capture Events". Upon the error, immediately disable "Capture Events" in Process Monitor.
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.
See there is a simple way to do this just follow this link to find your PATH variables in Advanced setting
https://docs.oracle.com/en/database/oracle/r-enterprise/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0
Now it is highly unlikely that you will be having more than a handful PATH variables so I recommend checking each of theses PATH variable and whichever is faulty just remove it
Or, just add a new PATH variable with the path to your python library files

Problems Installing PostgreSQL 9.2

I've been trying to install the 64bit version of PostgreSQL 9.2 for Windows on my machine (Windows 7 64bit) and get this error:
The environment variable COMPSPEC does not seem to point to the cmd.exe or there is a trailing semi colon present.
I've installed it as Administrator.
I disabled the antivirus (Microsoft Security Essentials) and the firewall.
Running:
"%COMSPEC%" /C "echo test ok"
returned test ok
I've checked my System Environment Variables for trailing semi colon and I couldn't find any.
I then installed the 32bit version and managed to get to the end of the install with a different error message stating: Problem running post-install step. Installation may not complete correctly Error reading the C:\Program Files (x86)\PostgreSQL\9.2\data\postgresql.conf but there is no postgresql.conf file in that directory. It did install the application and when I try to connect the server with the red X on it it says fail at the bottom and it won't connect after I type in my password.
How can I connect to this server connection?
ComSpec is a generic error message for any installation failure.
Identifying the problem
Navigate to below path
c:\Users\XXXXXX\AppData\Local\Temp
Open 'bitrock_installer_XXXX.log'
Check, if you are getting below error:
Script stderr:
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command, operable program or batch file.
Error running
C:\Users\XXXXX\AppData\Local\Temp/postgresql_installer_47b21c4ea1/temp_check_comspec.bat :
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command,
operable program or batch file.
This is a problem with '8.3 file names and directories' (e.g. '\Postgres Install' -> '\POSTGR~1')
Microsoft article on disabling 8.3 file names and directories: https://support.microsoft.com/en-gb/kb/121007
Solution:
Open command prompt in admin mode
Execute following command to change the format based on your drive or all drives
Sample commands:
fsutil 8dot3name set 1" - disable 8dot3 name creation on all volumes
fsutil 8dot3name set C: 1" - disable 8dot3 name creation on c:
Execute the installation as a user having admin privileges
After install, consider resetting the 8dot3name setting to default (2) to avoid unintended consequences
Hope it solves the problem!
Very easy fix:
Just open Advanced System Settings in Control Panel and create a new System Variable( in the System Variable instead of User Variable section).
In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.
Alternative fix:
If you have already the ComSpec variable in the System Variable section, remove the ;at the end of it this should fix it.
It's not COMPSPEC it's just COMSPEC. Please show the output of:
echo %COMSPEC%
Note that COMSPEC could be set to something different in the Administrator account you're running the installer as. I'm not sure how to find that out, but it might appear in the PostgreSQL installer log, so please upload that and link to it in your post. See Reporting an installation error for info on where to get the installer log.
See the PostgreSQL for Windows FAQ entry Check the COMSPEC environment variable.
Here's a report I made suggesting that the installer should test for this explicitly and here's my blog post on the topic.
I got the same problem, and i found in the log:
Script stderr:
'C:\Users\S300' is not recognized as an internal or external command,
operable program or batch file.
Error running C:\Users\S300 (i5)\AppData\Local\Temp/postgresql_installer_56caeadbd6/temp_check_comspec.bat : 'C:\Users\S300' is not recognized as an internal or external command,
operable program or batch file.
I change in User Variables TEMP to D:\TEMP and TMP to D:\TEMP.
And Solved My Problem.
In my case , the Installer was in %USERPROFILE%\DownloadsP{ Windows download folder}, I moved the installer to desktop and ran again. weird it worked lol.
I had a similar problem. After installation, the data folder contained no postgres.conf file. It only contained a single folder named "pg_log".
I described the solution that I used here: Postgres Installation Error reading file postgresql.conf
Basically, it would be helpful to check if the user has full permissions for the postgres folder, and run "init_db" and "pg_ctl start" commands again. If the path contains a space character, try using a relative path for the pg_ctl data folder argument.
I'm running Windows Server 2003 R2, and I have been unable to resolve this problem with the installer, so I resorted to using the binary PostgreSQL package. Hopefully this will be an alternative for others who do not want to perform an OS reinstall.
First, some background (hopefully useful to the developers)
It started out with the postgres service failing to start (the server had been running reliably for over a year). I assumed it was a corrupted PostgreSQL installation, so I uninstalled and attempted to reinstall. I encountered the following error:
There has been an error.
The environment variable COMSPEC does not seem to point to the cmd.exe or there is a trailing semicolon present.
Please fix this variable and restart installation.
However, the COMSPEC variable is set properly, verified with:
echo %COMSPEC%
C:\WINDOWS\system32\cmd.exe
and:
"%COMSPEC%" /C "echo test ok"
test ok
Since this is Windows Server 2003, there is no UCA wrapper around the Administrator account, so that is not causing the problem.
Manual Installation
NET USER postgres /ADD
C:\pgsql\bin\initdb.exe -U postgres -A password -E utf8 -W -D C:\pgsql\data
runas /user:postgres "C:\pgsql\bin\pg_ctl -D C:/pgsql/data -l C:/pgsql/logfile.txt start"
just do it run as administrator and change the environment system variable
like create a new variable 'ComSpec' and value type 'C:\Windows\system32\cmd.exe'.
If the installer exe is on a network share that mapped drive might actually not be accessible to the installer as it runs as administrator. This can often happen in some virtual machine arrangements such as running windows in a parallels VM. Copy the installer to a local drive first and you won't have a problem.
What worked for me after trying to enter the commandline given her in cmd.exe
I found it was named cmd1.exe in system32.. so i copied the file and renamed it as cmd.exe and installation finished
Open Environment Variables, you can do this on Windows 7 by typing environment variables in the Search program and files bar when pressing the start button at the bottom left of the desktop. And create a new System Variable(in the 'System Variable' instead of 'User Variable' section).
In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.
That's all. Hope it works!
Alternative fix:
If you already got the ComSpec variable in the System Variable section, remove the ; at the end of it this should fix it.
First find the path to cmd.exe(mostly it is C:\Windows\System32\cmd.exe).
Go to the enviornment variable and add this path to system variable path.And also create new variable in user variable called ComSpec and add this path as value. And you are ready to go.

Basic windows commands (ping, ipconfig) need admin rights - looking for an option

On my main pc (Win 7 64bit) basic windows commands like ping and ipconfig suddenly need admin rights.
If I start a normal command-line window, these commands are not found anymore ("X is not recognized as an internal or external command, operable program or batch file.")
If I start the command-line window with "Run as Administrator" everything works as expected.
On my second PC (Win 7 32 bit) I do not need admin rights.
And I strongly believe that I did not need admin rights on my main pc a couple of weeks ago. Something must have changed, thus I think there must be some (registry) switch or something.
any ideas? thanks a lot
[edit]
I am still the admin user - just starting cmd normally, not with "run as admin"
[edit2]
It indeed was the PATH, variable. Problem was, that Path was saved as the wrong type of string in the registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
has to be a REG_EXPAND_SZ as explained in this thread. Path being of the wrong type of string made it unable to expand %SystemRoot%. Make sure that both your system PATH as well as your user PATH environment variables are of type REG_EXPAND_SZ.
In an effort to narrow down the issue try the following:
open command prompt
make sure you are on the C:\ directory
type this: windows\system32\ipconfig /all
That will point to the default location for the command... You can also follow the path out to see if the ipconfig.exe is there in the first place. If that doesn't work or the file is not there, it could be corrupt or you could possibly have a virus designed to disable these commands.
Srart normal cmd prompt and look at output of the following commands
set path
dir %windir%\system32\ping.exe
dir %windir%\syswow64\ping.exe
dir %windir%\sysnative\ping.exe
Thought, they will show you a problem. May be ping is not found by %path% or somehow...

File Access takes me to command prompt rather than Explorer

Whenever I go to my command prompt and type a "c:\temp" or any other file/directory, it takes me to the command prompt rather than the file explorer. Can somebody please tell me how I can fix this so that all file/directory access from cmd takes me to the file explorer.
I have a Win2k3 64bit machine. Has this got anything to do with the 32bit/64bit explorer ?
To run Windows Explorer from command prompt you must type name of the executable:
explorer.exe
or just
explorer
To open a certain folder, pass the path as an arguments. Details here:
Command-Line Switches for Windows Explorer (MSDN KB)
See examples.
To open Explorer at the directory where your cmd is operating you can use
start .
and at a parent directory you can use
start ..

Resources