批处理脚本集ENV。可变启动OC4J并删除ENV。变量 [英] Batch script for set env. variable startup OC4J and remove env. variable

查看:152
本文介绍了批处理脚本集ENV。可变启动OC4J并删除ENV。变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本地计算机上安装Oracle客户机(11.2.0)和OC4J服务器(甲骨文货柜J2EE 10G(10.1.3.5.0)(建090727.2000.36696)),两者都使用 ORACLE_HOME 环境变量,所以我需要重新设置 ORACLE_HOME 指向服务器文件夹只有当服务器启动

on local computer are installed an Oracle client (11.2.0) and an OC4J Server (Oracle Containers for J2EE 10g (10.1.3.5.0) (build 090727.2000.36696)), both of them are using the ORACLE_HOME enviroment variable so I need to set ORACLE_HOME pointing to server folder only when server starts

我想生成批处理文件,必须做到:

I'm trying to generate batch file that must do:


  1. 设置环境变量 ORACLE_HOME

  2. 启动OC4J服务器

  3. 请解除 ORACLE_HOME 变量

  1. Set enviroment variable ORACLE_HOME
  2. Start up OC4J server
  3. Unset ORACLE_HOME variable

我这个脚本尝试,但第三个语句从未运行。

I'm trying with this script but the third statement never runs.

call setx -m ORACLE_HOME "C:\Servers\oc4j_extended_101350" 
call C:\Servers\oc4j_extended_101350\bin\oc4j -start 
call REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V ORACLE_HOME

所有这些命令工作正常单独执行。但是,在同一批次脚本启动OC4J从不的目的。任何想法我怎么能做到这一点的作品?

All of this commands works fine executing individually. But, on the same batch script the Start up OC4J "never" ends. Any idea how can i do this works?

任何帮助将AP preciated

Any help would be appreciated

推荐答案

该批处理文件来启动Oracle服务器只需要以下2行:

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

这就是它,如果 oc4j.exe 不是一个控制台应用程序,因此启动 oc4j.exe 导致关闭命令的过程。

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.

否则使用:

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.

有关执行批处理文件 ORACLE_HOME 命令过程在其环境表设置为在批处理文件中指定。

For the command process executing the batch file ORACLE_HOME is set in its environment table as specified in the batch file.

在启动Oracle服务器的这个环境表是由Windows Oracle服务器,包括复制 ORACLE_HOME 目前定义。什么在Windows注册表中定义并不重要,没有考虑到。 Oracle服务器不看是否存在同样的 ORACLE_HOME 设置为所有,如果是这样与价值父进程或其他程序并行运行。

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.

一个简单的例子,由Windows演示环境表管理。

A simple example to demonstrate environment table management by Windows.


  1. 打开一个命令提示符窗口,输入集合X =您好

  2. 键入集合X ,你会看到 X =您好

  3. 执行启动从而打开第二个命令提示符窗口。

  4. 在第二个命令提示符窗口中键入集合X ,你会得到显示也 X =您好

  5. 切换回第一个命令提示符窗口,然后运行设置X =喜

  6. 键入这第一个命令提示符窗口集合X ,你会看到 X =喜

  7. 再次切换到第二个命令行窗口,键入集合X 键,你仍然可以看到设置X =您好

  1. Open a command prompt window and enter set x=Hello.
  2. Type set x and you see x=Hello.
  3. Execute start resulting in opening a second command prompt window.
  4. Type in this second command prompt window set x and you get displayed also x=Hello.
  5. Switch back to first command prompt window and run set x=Hi.
  6. Type in this first command prompt window set x and you see x=Hi.
  7. 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.

执行中的第二个命令窗口设置X =再见集合X 验证。

Execute in second command window set x=Bye and verify it with set x.

切换回第一个命令行窗口,输入集合X

Switch back to first command window and enter set x.

它仍然是输出 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.

切换到第二个命令窗口并输入设置path = 从这个过程的环境删除表中的环境变量的 PATH

Switch to second command window and enter set path= to delete environment variable PATH from environment table of this process.

输入设置路径,你会得到只是显示

Enter set path and you get displayed just

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


发生了什么事与系统的 PATH

What happened with system PATH?

系统的 PATH 以及用户帐户相关的 PATH 仍然在Windows注册表中设置和共建 PATH 作为新流程从桌面浏览器启动处理。但在第二个和第三个命令过程中的环境表,没有环境变量的 PATH 了。这两个过程现在必须工作,没有环境变量的 PATH 。当然,第一个命令过程和所有其他正在运行的进程的 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.

这篇关于批处理脚本集ENV。可变启动OC4J并删除ENV。变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆