Oracle 10G之后发布了instant client,这对于原来的安装客户端来说,真的是一大利好消息。
下载地址可以到OTN上找一下。
虽然是免安装,但是在环境配置上需要花不少的力气。比如path的修改,类似原来9i的注册表信息(有些应用程序需要使用)的导入等等
下面的VBS代码完成以上所有的工作,你只需要另外做一件事,就是将tnsnames.ora与sqlnet.ora复制到同一个目录下面就可以了。
经测试PB8.0可以使用,O84 Oracle8/8i (8.x.4+)、O90 Oracle9i (9.0.1);后台数据库9i 10G均可以运行。
--------------------------------代码复制线-----------------------------------
'
' oracle instant client 免安装环境设置脚本
'*********************************************************************
' 默认为D:\oracle 如果不是请更改脚本
' BY:owen 2008-01-14
' QQ:123637765
'**********************************************************************
On Error Resume Next
Dim oWshShell, sOldPath
Const csPath="D:\oracle"
'上面改为你需要添加的目录。 注意格式
const csRegOracle = "HKLM\SOFTWARE\ORACLE\"
Set oWshShell = WScript.CreateObject("WScript.Shell")
'设置path
sOldPath=oWshShell.RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment\path")
oWshShell.RegWrite "HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment\path", sOldPath+ ";" +csPath+";" , "REG_SZ"
'增加两个环境变量
oWshShell.Environment("system").Item("TNS_ADMIN")=csPath
oWshShell.Environment("system").Item("NLS_LANG")="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
'oracle 注册表导入HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
'HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 先删除( 删除部分未完成) 后新建
oWshShell.RegWrite csRegOracle
oWshShell.RegWrite csRegOracle+"ORACLE_HOME",csPath
oWshShell.RegWrite csRegOracle+"ORACLE_HOME_NAME" ,"OraHome"
oWshShell.RegWrite csRegOracle+"NLS_LANG","SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
oWshShell.RegWrite csRegOracle+"TNS_ADMIN",csPath
oWshShell.RegWrite csRegOracle + "ALL_HOMES\"
oWshShell.RegWrite csRegOracle + "ALL_HOMES\" + "HOME_COUNTER","1"
oWshShell.RegWrite csRegOracle + "ALL_HOMES\" + "DEFAULT_HOME","OraHome"
oWshShell.RegWrite csRegOracle + "ALL_HOMES\" + "LAST_HOME","0"
oWshShell.RegWrite csRegOracle + "ALL_HOMES\"+"\ID0\"
oWshShell.RegWrite csRegOracle + "ALL_HOMES\"+"\ID0\"+"NAME","OraHome"
oWshShell.RegWrite csRegOracle + "ALL_HOMES\"+"\ID0\"+"PATH",csPath
oWshShell.RegWrite csRegOracle + "ALL_HOMES\"+"\ID0\"+ "NLS_LANG","NA"
oWshShell.RegWrite csRegOracle + "HOME0\"
oWshShell.RegWrite csRegOracle + "HOME0\" + "ID","0"
oWshShell.RegWrite csRegOracle + "HOME0\" + "ORACLE_GROUP_NAME" ,"Oracle - OraHome"
oWshShell.RegWrite csRegOracle + "HOME0\" + "ORACLE_HOME_NAME","OraHome"
oWshShell.RegWrite csRegOracle + "HOME0\" + "ORACLE_HOME",csPath
oWshShell.RegWrite csRegOracle + "HOME0\" + "NLS_LANG","SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
oWshShell.RegWrite csRegOracle + "HOME0\" + "ORACLE_HOME_KEY","Software\ORACLE\HOME0"
Msgbox ( "已经成功设置ORACLE环境")
--------------------------------代码复制线-----------------------------------
将以上代码复制后另存成oracle.vbs 运行即可