系统找不到指定的路径(批处理文件)-使用带空格的路径-PENTAHO Spoon.bat(pdi-ce-7.1.0.0-12) [英] The system cannot find the path specified (Batch file) - Using path with white spaces - PENTAHO spoon.bat (pdi-ce-7.1.0.0-12)
问题描述
我正在尝试从PENTAHO(pdi-ce-7.1.0.0-12)执行批处理文件"spoon.bat",但是出现错误.
I'm trying to execute a batch file "spoon.bat" from PENTAHO (pdi-ce-7.1.0.0-12), but there is an error.
发现错误的批处理文件的一部分:
Part of batch file where the error is found:
if "%SPOON_CONSOLE%"=="1" set PENTAHO_JAVA=C:\Program Files (x86)\Java\jre1.8.0_121\bin\java.exe
if not "%SPOON_CONSOLE%"=="1" set PENTAHO_JAVA=C:\Program Files (x86)\Java\jre1.8.0_121\bin\javaw.exe
set IS64BITJAVA=0
call "%~dp0set-pentaho-env.bat"
但是我收到下一个错误:
But I receive next below error:
The system cannot find the path specified
错误是当我尝试将找到java.exe或javaw.exe的路径分配给"PENTAHO_JAVA"时.
The error is when I'm trying to assign the path where java.exe or javaw.exe are found to "PENTAHO_JAVA".
我用双引号修改了路径,但是不起作用;而且我也修改为:
I've modified the path with double quote mark, but doesn't work; and also I've modified as:
if "%SPOON_CONSOLE%"=="1" set "PENTAHO_JAVA=C:\<Program Files (x86)>\Java\jre1.8.0_121\bin\java.exe"
有什么想法声明如何修复它吗?
Any idea to how declare it to fix it?
推荐答案
在何处引用了环境变量PENTAHO_JAVA
?
Where is the environment variable PENTAHO_JAVA
referenced?
必须用"%PENTAHO_JAVA%"
引用,因为分配给该环境变量的字符串包含空格或&()[]{}^=;!'+,`~
之类的字符.在最后一个帮助页面上的最后一个段落中的命令提示符窗口cmd /?
中运行时,Windows命令解释器输出的帮助中对此进行了解释.
It must be referenced with "%PENTAHO_JAVA%"
because the string assigned to this environment variable contains characters like a space or &()[]{}^=;!'+,`~
. This is explained in help of Windows command interpreter output on running in a command prompt window cmd /?
in last paragraph on last help page.
当然也可以使用已添加的必需双引号定义环境变量,即使用:
It is of course also possible to define the environment variable with the necessary double quotes already added, i.e. use:
if "%SPOON_CONSOLE%"=="1" set "PENTAHO_JAVA="%ProgramFiles(x86)%\Java\jre1.8.0_121\bin\java.exe""
if not "%SPOON_CONSOLE%"=="1" set "PENTAHO_JAVA="%ProgramFiles(x86)%\Java\jre1.8.0_121\bin\javaw.exe""
set "IS64BITJAVA=0"
call "%~dp0set-pentaho-env.bat"
但是不建议这样做.最好是使用
But this is not recommended. Better would be to use
if "%SPOON_CONSOLE%"=="1" set "PENTAHO_JAVA=%ProgramFiles(x86)%\Java\jre1.8.0_121\bin\java.exe"
if not "%SPOON_CONSOLE%"=="1" set "PENTAHO_JAVA=%ProgramFiles(x86)%\Java\jre1.8.0_121\bin\javaw.exe"
set "IS64BITJAVA=0"
call "%~dp0set-pentaho-env.bat"
和引用环境变量PENTAHO_JAVA
用双引号引起来,需要在双引号中指定其值.
and reference environment variable PENTAHO_JAVA
enclosed in double quotes where it is necessary to specify its value enclosed in double quotes.
示例:
@echo off
rem Get path of latest installed Java directly from Windows registry.
for /F "skip=1 tokens=1,2*" %%N in ('%SystemRoot%\System32\reg.exe QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\javaws.exe" /v Path 2^>nul') do if /I "%%N" == "Path" set "PENTAHO_JAVA=%%P" & goto JavaPathFound
rem Path of Java not found in registry, search for 32-bit Java in the default
rem program files folders of 64-bit and 32-bit Windows and take first found.
if "%ProgramFiles(x86)%" == "" goto Windows_x86
for /R "%ProgramFiles(x86)%" %%I in (java*.exe) do set "PENTAHO_JAVA=%%~dpI" & goto JavaPathFound
:Windows_x86
for /R "%ProgramFiles%" %%I in (java*.exe) do set "PENTAHO_JAVA=%%~dpI" & goto JavaPathFound
echo Error: Java binary directory not found.
echo/
pause
goto :EOF
:ErrorJavaEXE
echo Error: File %PENTAHO_JAVA% not found.
echo/
pause
goto :EOF
:JavaPathFound
if not "%PENTAHO_JAVA:~-1%" == "\" set "PENTAHO_JAVA=%PENTAHO_JAVA%\"
if "%SPOON_CONSOLE%" == "1" (
set "PENTAHO_JAVA=%PENTAHO_JAVA%java.exe"
) else (
set "PENTAHO_JAVA=%PENTAHO_JAVA%javaw.exe"
)
rem Check existence of Java executable to run.
if not exist "%PENTAHO_JAVA%" goto ErrorJavaEXE
"%PENTAHO_JAVA%" -version
call "%~dp0set-pentaho-env.bat"
要了解所使用的命令及其工作方式,请打开命令提示符窗口,在其中执行以下命令,并非常仔细地阅读每个命令显示的所有帮助页面.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
-
call /?
-
echo /?
-
for /?
-
goto /?
-
if /?
-
pause /?
-
reg /?
-
reg query /?
-
rem /?
call /?
echo /?
for /?
goto /?
if /?
pause /?
reg /?
reg query /?
rem /?
另请阅读有关使用命令重定向操作符的Microsoft文章. 2>nul
的说明,根据该说明,必须在此导入代码中,在 FOR 命令行中使用转号字符^
对重定向运算符进行转义.并阅读使用Windows批处理文件的单行包含多个命令的答案,以获取&
运算符的解释.
Read also the Microsoft article about Using Command Redirection Operators for an explanation of 2>nul
whereby redirection operator must be escaped in this batch code on FOR command line with caret character ^
. And read answer on Single line with multiple commands using Windows batch file for an explanation of &
operator.
这篇关于系统找不到指定的路径(批处理文件)-使用带空格的路径-PENTAHO Spoon.bat(pdi-ce-7.1.0.0-12)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!