问题
I have folder run
in folder system32
. When I run cmd
from within Total Commander opening a command prompt window with C:\Users\admin
as current directory and want to go into that folder, the following error message is output:
System cannot find the path specified.
When I open cmd
directly in folder run
, it works perfect. Why?
The command prompt window on opening in C:\Windows\System32\run
:
C:\Windows\System32\run>cd..
C:\Windows\System32>cd run
C:\Windows\System32\run>
The command prompt window on simply running cmd
:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Všetky práva vyhradené.
C:\Users\admin>cd..
C:\Users>cd..
C:\>cd windows
C:\Windows>cd system32
C:\Windows\System32>cd run
Systém nemôže nájst’ zadanú cestu.
回答1:
There is not only 1 %SystemRoot%\System32
on Windows x64. There are 2 such directories.
The real %SystemRoot%\System32
directory is for 64-bit applications. This directory contains a 64-bit cmd.exe
.
But there is also %SystemRoot%\SysWOW64
for 32-bit applications. This directory is used if a 32-bit application accesses %SystemRoot%\System32
. It contains a 32-bit cmd.exe
.
32-bit applications can access %SystemRoot%\System32
for 64-bit applications by using %SystemRoot%\Sysnative
in path.
For more details see the Microsoft documentation about File System Redirector.
So I think you have created the subdirectory run
in %SystemRoot%\System32
for 64-bit applications and run 32-bit cmd
for which this directory does not exist as there is no subdirectory run
in %SystemRoot%\SysWOW64
which is %SystemRoot%\System32
for 32-bit cmd.exe
.
Or you have created the subdirectory run
in %SystemRoot%\System32
for 32-bit applications and run 64-bit cmd
for which this directory does not exist as there is no subdirectory run
in %SystemRoot%\System32
because this subdirectory exists only in %SystemRoot%\SysWOW64
.
You could use following at top of your batch file in case of subdirectory run
is in %SystemRoot%\System32
for 64-bit applications:
@echo off
set "SystemPath=%SystemRoot%\System32"
if not "%ProgramFiles(x86)%"=="" (
if exist %SystemRoot%\Sysnative\* set "SystemPath=%SystemRoot%\Sysnative"
)
Next you need to call every console application in System32\run
directory with %SystemPath%
in your batch file, for example %SystemPath%\run\YourApp.exe
.
How it works?
On Windows x86 there is no environment variable ProgramFiles(x86) and therefore there is really only 1 %SystemRoot%\System32
as defined at top.
On Windows x64 there is the environment variable ProgramFiles(x86) with a value. On Windows x64 it is additionally checked if there are files in %SystemRoot%\Sysnative
. In this case the batch file is executed with 32-bit cmd.exe
and only in this case %SystemRoot%\Sysnative
needs to be used at all. Otherwise %SystemRoot%\System32
can be used also on Windows x64 as when the batch file is started with 64-bit cmd.exe
, this is the directory containing the 64-bit console applications (and your subdirectory run
).
Note: %SystemRoot%\Sysnative
is not a directory! It is not possible to cd
to %SystemRoot%\Sysnative
or use if exist %SystemRoot%\Sysnative
回答2:
You just need to:
Step 1: Go home directory of C:\ with typing cd.. (2 times)
Step 2: It appears now C:\>
Step 3: Type dir Windows\System32\run
That's all, it shows complete files & folder details inside target folder.
Details: I used Windows\System32\com
folder as example, you should type your own folder name etc. Windows\System32\run
来源:https://stackoverflow.com/questions/33638281/what-is-the-reason-for-the-error-message-system-cannot-find-the-path-specified