The batch file to start the Oracle server just needs the following 2 lines:
set "ORACLE_HOME=C:\Servers\oc4j_extended_101350"
C:\Servers\oc4j_extended_101350\bin\oc4j.exe -start
That's it if oc4j.exe
is not a console application and therefore command processor immediately continues processing the batch file after starting oc4j.exe
resulting in closing command process.
Otherwise use:
set "ORACLE_HOME=C:\Servers\oc4j_extended_101350"
start "Oracle Server" C:\Servers\oc4j_extended_101350\bin\oc4j.exe -start
Why this works?
Windows creates automatically a copy of the entire environment table of current process for the new process on creating a new process.
For the command process executing the batch file ORACLE_HOME
is set in its environment table as specified in the batch file.
On starting the Oracle server this environment table is copied by Windows for the Oracle server including ORACLE_HOME
as currently defined. What is defined in Windows registry does not matter and is not taken into account. The Oracle server does not see if there is also ORACLE_HOME
set at all and if so with which value for parent processes or other processes running parallel.
A simple example to demonstrate environment table management by Windows.
- Open a command prompt window and enter
set x=Hello
.
- Type
set x
and you see x=Hello
.
- Execute
start
resulting in opening a second command prompt window.
- Type in this second command prompt window
set x
and you get displayed also x=Hello
.
- Switch back to first command prompt window and run
set x=Hi
.
- Type in this first command prompt window
set x
and you see x=Hi
.
Switch again to second command window, type set x
and you still see set x=Hello
.
This second command process has got a copy of first command process. So what is changed now in the environment table of first command process is not visible for second command process.
Execute in second command window set x=Bye
and verify it with set x
.
Switch back to first command window and enter set x
.
It is still output x=Hi
because also the parent process does not get back what the child process modifies in its copy of the environment table.
Switch to second command window and enter set path=
to delete environment variable PATH from environment table of this process.
- Execute once more
start
to open from second command window a third command window.
Enter set path
and you get displayed just
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
What happened with system PATH?
System PATH as well as user account related PATH are still set in Windows registry and build together PATH for new processes started from desktop Explorer process. But in the environment tables of second and third command process there is no environment variable PATH anymore. Those two processes must work now without environment variable PATH. Of course for the first command process and all other running processes PATH still exists in their environment tables.