简体   繁体   中英

'c:\Program' is not recognized as an internal or external command, operable command or batch file

After successful installation of Oracle SOA Suite 12c, I'm trying to install RCU.

When I try to execute an RCU batch file from the command prompt, I get this error:

'c:\Program' is not recognized as an internal or external command, operable command or batch file

The batch file is located in the below path:

C:\Oracle\Middleware\Oracle_Home\oracle_common\bin

我的 cmd 窗口的屏幕截图

This is my PATH environment variable value:

C:\app\gadmin\product\18.0.0\dbhomeXE\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\PuTTY\;C:\Program Files\SafeNet\Authentication\SAC\x64;C:\Program Files\SafeNet\Authentication\SAC\x32

and this in my PATHTEXT environment variable value:

.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

The batch file I'm trying to run :

rcu.bat

@REM Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
@REM Wrapper script to launch Oracle home base rcu script
@echo off
setlocal

SET INTERNAL_SCRIPT=rcu_internal.bat
SET WLS_ORACLE_HOME=C:\Oracle\Middleware\Oracle_Home
SET INTERNAL_SCRIPTPATH=
IF EXIST %WLS_ORACLE_HOME% (
        SET INTERNAL_SCRIPTPATH="%WLS_ORACLE_HOME%\oracle_common\bin"
) ELSE (
        SET INTERNAL_SCRIPTPATH=%~dp0
)
CALL %INTERNAL_SCRIPTPATH%\%INTERNAL_SCRIPT% %*

rcu_internal.bat


@REM Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.

@echo off

setlocal



rem ORACLE_HOME is the parent directory of the "oracle_common\bin" dir where the rcu script is located
SET SCRIPT_PATH=%~dp0
FOR %%i IN ("%SCRIPT_PATH%") DO SET SCRIPT_PATH=%%~fsi

@REM Set the ORACLE_HOME relative to this script...
FOR %%i IN ("%SCRIPT_PATH%\..\..") DO SET ORACLE_HOME=%%~fsi

@set LOG_LOCATION_VAR=
@set LOG_LEVEL_VAR=
@set LOG_NAME_VAR=
@set LOG_FORMATTER_VAR=
@set TIMESTAMP_LOG_DIR_VAR=
@set PRETTY_NAME_VAR=
@set OPERATION1_NAME_VAR=
@set OPERATION2_NAME_VAR=
@set OPERATION1_CMDLINE_VAR=
@set OPERATION2_CMDLINE_VAR=
@set DBMS_OUTPUT_IN_SEPARATE_FILE_VAR=
@set RCU_PRODUCT_NAME_VAR=
@set RCU_TWO_PHASE_VAR=
@set ENABLE_JAVADB_VAR=

@if not "%RCU_TIMESTAMP_LOG_DIR%" == ""  set TIMESTAMP_LOG_DIR_VAR=-DRCU_TIMESTAMP_LOG_DIR=%RCU_TIMESTAMP_LOG_DIR%
@if "%RCU_TIMESTAMP_LOG_DIR%" == ""  set TIMESTAMP_LOG_DIR_VAR=-DRCU_TIMESTAMP_LOG_DIR=true
@if not "%RCU_LOG_LOCATION%" == ""  set LOG_LOCATION_VAR=-DRCU_LOG_LOCATION="%RCU_LOG_LOCATION%"
@if not "%RCU_LOG_LEVEL%" == ""  set LOG_LEVEL_VAR=-DRCU_LOG_LEVEL=%RCU_LOG_LEVEL%
@if "%RCU_LOG_LEVEL%" == ""  set LOG_LEVEL_VAR=-DRCU_LOG_LEVEL=NOTIFICATION
@if not "%RCU_LOG_NAME%" == ""  set LOG_NAME_VAR=-DRCU_LOG_NAME="%RCU_LOG_NAME%"
@if not "%RCU_LOG_FORMATTER%" == ""  set LOG_FORMATTER_VAR=-DRCU_LOG_FORMATTER=%RCU_LOG_FORMATTER%
@if not "%USE_PRETTY_NAMES%" == "" set PRETTY_NAME_VAR=-DUSE_PRETTY_NAMES=%USE_PRETTY_NAMES%
@if not "%RCU_OPERATION1_NAME%" == ""  set OPERATION1_NAME_VAR=-DRCU_OPERATION1_NAME=%RCU_OPERATION1_NAME%
@if not "%RCU_OPERATION2_NAME%" == ""  set OPERATION2_NAME_VAR=-DRCU_OPERATION2_NAME=%RCU_OPERATION2_NAME%
@if not "%RCU_OPERATION1_CMDLINE%" == ""  set OPERATION1_CMDLINE_VAR=-DRCU_OPERATION1_CMDLINE=%RCU_OPERATION1_CMDLINE%
@if not "%RCU_OPERATION2_CMDLINE%" == ""  set OPERATION2_CMDLINE_VAR=-DRCU_OPERATION2_CMDLINE=%RCU_OPERATION2_CMDLINE%
@if not "%RCU_DBMS_OUTPUT_IN_SEPARATE_FILE%" == ""  set DBMS_OUTPUT_IN_SEPARATE_FILE_VAR=-DRCU_DBMS_OUTPUT_IN_SEPARATE_FILE=%RCU_DBMS_OUTPUT_IN_SEPARATE_FILE%
@if not "%RCU_PRODUCT_NAME%" == ""  set RCU_PRODUCT_NAME_VAR=-DRCU_PRODUCT_NAME=%RCU_PRODUCT_NAME%
@if not "%USE_TWO_PHASE_RCU%" == "" set RCU_TWO_PHASE_VAR=-DUSE_TWO_PHASE_RCU=%USE_TWO_PHASE_RCU%
@if not "%ENABLE_JAVADB%" == "" set ENABLE_JAVADB_VAR=-DENABLE_JAVADB=%ENABLE_JAVADB%

@set RCU_ENV_VARS=%LOG_LOCATION_VAR% %LOG_LEVEL_VAR% %LOG_NAME_VAR% %LOG_FORMATTER_VAR% %TIMESTAMP_LOG_DIR_VAR% %PRETTY_NAME_VAR% %OPERATION1_NAME_VAR% %OPERATION2_NAME_VAR% %OPERATION1_CMDLINE_VAR% %OPERATION2_CMDLINE_VAR% %DBMS_OUTPUT_IN_SEPARATE_FILE_VAR% %RCU_PRODUCT_NAME_VAR% %RCU_TWO_PHASE_VAR% %ENABLE_JAVADB_VAR%

@set LAUNCH_MODE=%LAUNCH_MODE%
@set OH=%ORACLE_HOME%
@set RCU_HOME=%ORACLE_HOME%\oracle_common
@set OH_J2EE=%ORACLE_HOME%\j2ee\home

@set JLIB_DIR=%RCU_HOME%\jlib
@set JRE_DIR=%OH%\jdk\jre
@set RCUHELP_FILE=rchlp.jar

IF [%LANG%] == []  (
  FOR /F "tokens=3 delims= " %%G in ('reg query "hklm\system\controlset001\control\nls\language" /v Default') DO (
    IF [%%G] EQU [0407] (
      set RCUHELP_FILE=rchlp_de.jar
    ) ELSE IF [%%G] EQU [040c] (
      set RCUHELP_FILE=rchlp_fr.jar
    ) ELSE IF [%%G] EQU [040a] (
      set RCUHELP_FILE=rchlp_es.jar
    ) ELSE IF [%%G] EQU [0410] (
      set RCUHELP_FILE=rchlp_it.jar
    ) ELSE IF [%%G] EQU [0411] (
      set RCUHELP_FILE=rchlp_ja.jar
    ) ELSE IF [%%G] EQU [0412] (
      set RCUHELP_FILE=rchlp_ko.jar
    ) ELSE IF [%%G] EQU [0416] (
      set RCUHELP_FILE=rchlp_pt_BR.jar
    ) ELSE IF [%%G] EQU [0804] (
      set RCUHELP_FILE=rchlp_zh_CN.jar
    ) ELSE IF [%%G] EQU [0404] (
      set RCUHELP_FILE=rchlp_zh_TW.jar
    )
  )
) ELSE (  
  echo %LANG%|findstr /i "de" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_de.jar
  echo %LANG%|findstr /i "fr" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_fr.jar
  echo %LANG%|findstr /i "es" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_es.jar
  echo %LANG%|findstr /i "it" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_it.jar
  echo %LANG%|findstr /i "ja" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_ja.jar
  echo %LANG%|findstr /i "ko" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_ko.jar
  echo %LANG%|findstr /i "pt_BR" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_pt_BR.jar
  echo %LANG%|findstr /i "zh_CN" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_zh_CN.jar
  echo %LANG%|findstr /i "zh_TW" >nul:
  if not errorlevel 1 set RCUHELP_FILE=rchlp_zh_TW.jar
)

@set RCU_CLASSPATH=%JLIB_DIR%\rcu.jar
@set HELPSET_CLASSPATH=%JLIB_DIR%\%RCUHELP_FILE%

@set PATH=%RCU_HOME%\bin;%PATH%

@set CLASSPATH=%RCU_CLASSPATH%;%HELPSET_CLASSPATH%

rem If no parameter passed, RCU should start run as silent mode.

@if  "%JAVA_HOME%" == "" set JAVA_HOME=%JRE_DIR%
@if not "%JAVA_HOME%" == "" if exist %JAVA_HOME%\jre\bin\javaw.exe set JAVA_HOME=%JAVA_HOME%\jre\

if NOT exist "%JAVA_HOME%\bin\java.exe" (
        if exist "%RCU_HOME%\..\oui\bin\getVariable.cmd" (
        @REM INVOKE SCRIPT TO SET THE JAVA_HOME
        CALL %RCU_HOME%\..\oui\bin\getVariable.cmd JAVA_HOME JAVA_HOME
     )
)

if NOT exist "%JAVA_HOME%\bin\java.exe" (
    if exist "%RCU_HOME%\jdk" (
        @REM SET THE JAVA_HOME to oracle_common/jdk
        set JAVA_HOME=%RCU_HOME%\jdk
     )
)

for %%i in ("%JAVA_HOME%") do set JAVA_HOME=%%~fsi

if NOT exist "%JAVA_HOME%\bin\java.exe" (
     echo Unable to locate java at the following location: %JAVA_HOME%\bin\java. Please set the correct value for JAVA_HOME or ORACLE_HOME and try again.
         SET ERRORLEVEL=1
         goto end

)


if "%~1"=="" goto console 
%JAVA_HOME%\bin\java %RCU_JAVA_OPTIONS% -DRCU_HOME=%RCU_HOME% -DSQLPLUS_HOME=%OH% -DORACLE_HOME=%OH% %RCU_ENV_VARS% -DLAUNCH_MODE=%LAUNCH_MODE% -mx128m  -classpath %CLASSPATH% oracle.sysman.assistants.rcu.Rcu -lockSchemas false %*
goto end

:console
%JAVA_HOME%\bin\java -DRCU_HOME=%RCU_HOME% -DSQLPLUS_HOME=%OH% -DORACLE_HOME=%OH% -DRANDOMIZE_PASSWORDS=true %RCU_ENV_VARS% -DLAUNCH_MODE=%LAUNCH_MODE% -mx128m %RCU_JAVA_OPTIONS% -classpath %CLASSPATH% oracle.sysman.assistants.rcu.Rcu

:end
exit /B %ERRORLEVEL%

I suggest to modify rcu.bat to:

@REM Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
@REM Wrapper script to launch Oracle home base rcu script
@ECHO OFF
SETLOCAL EnableExtensions DisableDelayedExpansion

SET "INTERNAL_SCRIPT=rcu_internal.bat"
SET "WLS_ORACLE_HOME=C:\Oracle\Middleware\Oracle_Home"
SET "INTERNAL_SCRIPTPATH="
IF EXIST "%WLS_ORACLE_HOME%" (
    SET "INTERNAL_SCRIPTPATH=%WLS_ORACLE_HOME%\oracle_common\bin\"
) ELSE (
    SET "INTERNAL_SCRIPTPATH=%~dp0"
)
CALL "%INTERNAL_SCRIPTPATH%%INTERNAL_SCRIPT%" %*

ENDLOCAL

Every argument string referencing a file or folder must be enclosed in double quotes to be sure to work even on file/folder name without or with path contains a space or one of these characters &()[]{}^=;!'+,`~ .

The expression %~dp0 expands to full qualified path of the batch file which always ends with a backslash. Therefore %~dp0 should be never concatenated directly or indirectly as done here via environment variable INTERNAL_SCRIPTPATH with an additional backslash with a file/folder name. That would otherwise results in \\\\ in expanded path which Windows needs to correct to a single \\ before it passes the file/folder name with path to the file system. This is the reason for appending a backslash at end of %WLS_ORACLE_HOME%\\oracle_common\\bin and remove the backslash in argument string of command CALL .

The usage of command SETLOCAL just results in pushing the current directory path on stack and the pointer to the current list of environment variables. The state of the command extensions and the state of delayed environment variable expansion are not changed on using just SETLOCAL without any parameter. So the execution environment would be defined outside of the batch file. That is not good. A batch file should not depend on what other application or batch files set as execution environment. This batch file requires enabled command extensions and disabled delayed environment variable expansion to work independent on what is the full path of the batch file. Therefore the command SETLOCAL is used with the two optional arguments to define the required execution environment. Please read read this answer for details about the commands SETLOCAL and ENDLOCAL .

I recommend to read my answers on How to set environment variables with spaces? and on Why is no string output with 'echo %var%' after using 'set var = text' on command line? to understand why it is best practice to enclose the argument string variable=value for command SET in double quotes with first " left to variable name and not at beginning of the variable value. That makes a big difference.

The usage of SET INTERNAL_SCRIPTPATH="%WLS_ORACLE_HOME%\\oracle_common\\bin" results on the command line CALL %INTERNAL_SCRIPTPATH%\\%INTERNAL_SCRIPT% %* in the expanded command line:

CALL "C:\Oracle\Middleware\Oracle_Home\oracle_common\bin"\rcu_internal.bat %*

The first argument of command CALL is not quoted correct. The second " should be at end of the argument string after .bat and not somewhere in the middle. The suggested code above results in an always 100% correct first argument string for command CALL .

I suggest for rcu_internal.bat the following code:

@rem Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
@echo off
setlocal EnableExtensions DisableDelayedExpansion

@rem ORACLE_HOME is the parent directory of the "oracle_common\bin"
@rem directory where the rcu script is located.
@rem Set the ORACLE_HOME relative to this script...
for %%I in ("%~dp0..\..") do set "ORACLE_HOME=%%~fI"

@rem Make sure the ORACLE_HOME path does not end with a
@rem backslash even on being the root directory of a drive.
if "%ORACLE_HOME:~-1%" == "\" set "ORACLE_HOME=%ORACLE_HOME:~0,-1%"

@set "LOG_LOCATION_VAR="
@set "LOG_LEVEL_VAR="
@set "LOG_NAME_VAR="
@set "LOG_FORMATTER_VAR="
@set "TIMESTAMP_LOG_DIR_VAR="
@set "PRETTY_NAME_VAR="
@set "OPERATION1_NAME_VAR="
@set "OPERATION2_NAME_VAR="
@set "OPERATION1_CMDLINE_VAR="
@set "OPERATION2_CMDLINE_VAR="
@set "DBMS_OUTPUT_IN_SEPARATE_FILE_VAR="
@set "RCU_PRODUCT_NAME_VAR="
@set "RCU_TWO_PHASE_VAR="
@set "ENABLE_JAVADB_VAR="

@if defined RCU_TIMESTAMP_LOG_DIR set "TIMESTAMP_LOG_DIR_VAR=-DRCU_TIMESTAMP_LOG_DIR=%RCU_TIMESTAMP_LOG_DIR%"
@if not defined RCU_TIMESTAMP_LOG_DIR set "TIMESTAMP_LOG_DIR_VAR=-DRCU_TIMESTAMP_LOG_DIR=true"
@if defined RCU_LOG_LOCATION set "LOG_LOCATION_VAR=-DRCU_LOG_LOCATION="%RCU_LOG_LOCATION%" "
@if defined RCU_LOG_LEVEL set "LOG_LEVEL_VAR=-DRCU_LOG_LEVEL=%RCU_LOG_LEVEL%"
@if not defined RCU_LOG_LEVEL set "LOG_LEVEL_VAR=-DRCU_LOG_LEVEL=NOTIFICATION"
@if defined RCU_LOG_NAME set "LOG_NAME_VAR= -DRCU_LOG_NAME="%RCU_LOG_NAME%""
@if defined CU_LOG_FORMATTER set "LOG_FORMATTER_VAR= -DRCU_LOG_FORMATTER=%RCU_LOG_FORMATTER%"
@if defined USE_PRETTY_NAMES set "PRETTY_NAME_VAR= -DUSE_PRETTY_NAMES=%USE_PRETTY_NAMES%"
@if defined RCU_OPERATION1_NAME set "OPERATION1_NAME_VAR= -DRCU_OPERATION1_NAME=%RCU_OPERATION1_NAME%"
@if defined RCU_OPERATION2_NAME set "OPERATION2_NAME_VAR= -DRCU_OPERATION2_NAME=%RCU_OPERATION2_NAME%"
@if defined RCU_OPERATION1_CMDLINE set "OPERATION1_CMDLINE_VAR= -DRCU_OPERATION1_CMDLINE=%RCU_OPERATION1_CMDLINE%"
@if defined RCU_OPERATION2_CMDLINE set "OPERATION2_CMDLINE_VAR= -DRCU_OPERATION2_CMDLINE=%RCU_OPERATION2_CMDLINE%"
@if defined RCU_DBMS_OUTPUT_IN_SEPARATE_FILE set "DBMS_OUTPUT_IN_SEPARATE_FILE_VAR= -DRCU_DBMS_OUTPUT_IN_SEPARATE_FILE=%RCU_DBMS_OUTPUT_IN_SEPARATE_FILE%"
@if defined RCU_PRODUCT_NAME set "RCU_PRODUCT_NAME_VAR= -DRCU_PRODUCT_NAME=%RCU_PRODUCT_NAME%"
@if defined USE_TWO_PHASE_RCU set "RCU_TWO_PHASE_VAR= -DUSE_TWO_PHASE_RCU=%USE_TWO_PHASE_RCU%"
@if defined ENABLE_JAVADB set "ENABLE_JAVADB_VAR= -DENABLE_JAVADB=%ENABLE_JAVADB%"

@set "RCU_ENV_VARS=%LOG_LOCATION_VAR%%LOG_LEVEL_VAR%%LOG_NAME_VAR%%LOG_FORMATTER_VAR% %TIMESTAMP_LOG_DIR_VAR%%PRETTY_NAME_VAR%%OPERATION1_NAME_VAR%%OPERATION2_NAME_VAR%%OPERATION1_CMDLINE_VAR%%OPERATION2_CMDLINE_VAR%%DBMS_OUTPUT_IN_SEPARATE_FILE_VAR%%RCU_PRODUCT_NAME_VAR%%RCU_TWO_PHASE_VAR%%ENABLE_JAVADB_VAR%"

@set "OH=%ORACLE_HOME%"
@set "RCU_HOME=%ORACLE_HOME%\oracle_common"
@set "OH_J2EE=%ORACLE_HOME%\j2ee\home"

@set "JLIB_DIR=%RCU_HOME%\jlib"
@set "JRE_DIR=%OH%\jdk\jre"
@set "RCUHELP_FILE=rchlp.jar"

if not defined LANG (
    for /F "skip=1 tokens=3" %%G in ('%SystemRoot%\System32\reg.exe query "HKLM\System\CurrentControlSet\Control\Nls\Language" /v Default') do (
        if "%%G" == "0407" set "RCUHELP_FILE=rchlp_de.jar" & goto MoreVars
        if /I "%%G" == "040c" set "RCUHELP_FILE=rchlp_fr.jar" & goto MoreVars
        if /I "%%G" == "040a" set "RCUHELP_FILE=rchlp_es.jar" & goto MoreVars
        if "%%G" == "0410" set "RCUHELP_FILE=rchlp_it.jar" & goto MoreVars
        if "%%G" == "0411" set "RCUHELP_FILE=rchlp_ja.jar" & goto MoreVars
        if "%%G" == "0412" set "RCUHELP_FILE=rchlp_ko.jar" & goto MoreVars
        if "%%G" == "0416" set "RCUHELP_FILE=rchlp_pt_BR.jar" & goto MoreVars
        if "%%G" == "0804" set "RCUHELP_FILE=rchlp_zh_CN.jar" & goto MoreVars
        if "%%G" == "0404" set "RCUHELP_FILE=rchlp_zh_TW.jar" & goto MoreVars
    )
) else (
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "de" >nul && ( set "RCUHELP_FILE=rchlp_de.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "fr" >nul && ( set "RCUHELP_FILE=rchlp_fr.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "es" >nul && ( set "RCUHELP_FILE=rchlp_es.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "it" >nul && ( set "RCUHELP_FILE=rchlp_it.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "ja" >nul && ( set "RCUHELP_FILE=rchlp_ja.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "ko" >nul && ( set "RCUHELP_FILE=rchlp_ko.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "pt_BR" >nul && ( set "RCUHELP_FILE=rchlp_pt_BR.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "zh_CN" >nul && ( set "RCUHELP_FILE=rchlp_zh_CN.jar" & goto MoreVars )
    echo %LANG%|%SystemRoot%\System32\find.exe /C /I "zh_TW" >nul && ( set "RCUHELP_FILE=rchlp_zh_TW.jar" & goto MoreVars )
)

:MoreVars
@set "RCU_CLASSPATH=%JLIB_DIR%\rcu.jar"
@set "HELPSET_CLASSPATH=%JLIB_DIR%\%RCUHELP_FILE%"
@set "PATH=%RCU_HOME%\bin;%PATH%"
@set "CLASSPATH=%RCU_CLASSPATH%;%HELPSET_CLASSPATH%"

rem If no parameter passed, RCU should start run as silent mode.

if not defined JAVA_HOME (
    set "JAVA_HOME=%JRE_DIR%"
) else (
    if exist "%JAVA_HOME%\jre\bin\javaw.exe" set "JAVA_HOME=%JAVA_HOME%\jre"
)

if not exist "%JAVA_HOME%\bin\java.exe" (
    if exist "%RCU_HOME%\..\oui\bin\getVariable.cmd" (
        @rem INVOKE SCRIPT TO SET THE JAVA_HOME
        call "%RCU_HOME%\..\oui\bin\getVariable.cmd" JAVA_HOME JAVA_HOME
    )
)

if not exist "%JAVA_HOME%\bin\java.exe" (
    if exist "%RCU_HOME%\jdk\" (
        @rem Set the JAVA_HOME to oracle_common\jdk
        set "JAVA_HOME=%RCU_HOME%\jdk"
    )
)

for %%I in ("%JAVA_HOME%") do set "JAVA_HOME=%%~fI"

if not exist "%JAVA_HOME%\bin\java.exe" (
    echo Unable to locate Java at the following location: "%JAVA_HOME%\bin\java".
    echo Please set the correct value for JAVA_HOME or ORACLE_HOME and try again.
    @rem Command endlocal is implicit executed by cmd.exe
    exit /B 1
)

if not "%~1" == "" (
    "%JAVA_HOME%\bin\java.exe" %RCU_JAVA_OPTIONS% -DRCU_HOME="%RCU_HOME%" -DSQLPLUS_HOME="%OH%" -DORACLE_HOME="%OH%" %RCU_ENV_VARS% -DLAUNCH_MODE=%LAUNCH_MODE% -mx128m -classpath "%CLASSPATH%" oracle.sysman.assistants.rcu.Rcu -lockSchemas false %*
) else (
    "%JAVA_HOME%\bin\java.exe" -DRCU_HOME="%RCU_HOME%" -DSQLPLUS_HOME="%OH%" -DORACLE_HOME="%OH%" -DRANDOMIZE_PASSWORDS=true %RCU_ENV_VARS% -DLAUNCH_MODE=%LAUNCH_MODE% -mx128m %RCU_JAVA_OPTIONS% -classpath "%CLASSPATH%" oracle.sysman.assistants.rcu.Rcu
)

endlocal

Note: I hope, this revised batch file works because I could not test it.

The error message is caused by %JAVA_HOME%\\bin\\java not enclosed in " at end of the batch file.

It is faster and safer to check for existence of an environment variable using if defined instead of if not "variable" == "" if the command extensions are enabled as made sure in third line of this batch file. if not defined is better than if "variable" == "" .

The environment variables which finally build RCU_ENV_VARS are defined in a manner to avoid two or more spaces on command line between the arguments if one or more options are not defined on execution of this script. More than one space between the options is no problem, but it looks better to have just one space between each option and it can be easily achieved as it can be seen here.

The registry key ControlSet001 should be never used on registry queries. There is no guarantee that this registry key exists at all. There is CurrentControlSet which exists always. I have a PC on which ControlSet002 is the last known good control set, ControlSet003 is the current control set and ControlSet001 does not exist at all as defined automatically by Windows according to values in HKLM\\System\\Select .

Do not use [ and ] on comparing two strings. They have no special meaning for Windows command processor. It is more safe to use " for the two strings to compare with an IF condition. But please take into account that IF does not remove " from the strings before running the string comparison. So if the string on left side is enclosed in " , the string on right side must be also enclosed in " .

The string comparison operator is == and not EQU . EQU is mainly for comparing two integer values and is interpreted as string comparison operator only if one of the two numbers to compare cannot be converted successfully to a signed 32-bit integer value like on enclosing the two strings in square brackets or double quotes. See also my answer on Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files for a very detailed explanation how string comparisons are done by command IF .

There should be always a space left and a space right to == for 100% correct syntax as on if not "%~1" == "" on which cmd.exe does not need to make automatic corrections like on if not "%~1"=="" . The applied automatic correction can be seen on debugging the batch file on looking on the IF command line really executed after parsing and processing the command line with the IF condition and the entire command block(s). Well, for debugging the batch file all @ are counterproductive with the exception of the first two.

%JAVA_HOME%\\bin\\java in the last few lines of the batch file which was not enclosed in double quotes was cause of the error. After enclosing it in double quotes the batch file executed successfully

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM