使用 VBS 和注册表确定安装了哪个版本和 32 位与 64 位 oracle 驱动程序

问题描述 投票:0回答:1

我想使用 VBS 读取注册表以列出服务器上的一些信息,包括驱动程序。

VBS:

REM Run this file with the following command:
REM cscript  drivers.vbs | clip

WScript.Echo "------------------------------------------------"

Const HKEY_LOCAL_MACHINE = &H80000002

'Get Server Name
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputerName = wshNetwork.ComputerName
WScript.Echo "Computer Name: " & strComputerName

'Get Driver Names  
strComputer = "."
 
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes


For i = 0 to UBound(arrValueNames)
    strValueName = arrValueNames(i)
    objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue    
    Wscript.Echo arrValueNames(i) & " -- " & strValue
Next

Set objShell = WScript.CreateObject("WScript.Shell")

'Get Oracle Environment variables
WScript.Echo "TNS_ADMIN=" & objShell.Environment("SYSTEM").Item("TNS_ADMIN")
WScript.Echo "ORACLE_HOME=" & objShell.Environment("SYSTEM").Item("ORACLE_HOME")


WScript.Echo "------------------------------------------------"

输出:

------------------------------------------------
Computer Name: WLDL2532
SQL Server -- Installed
Client Access ODBC Driver (32-bit) -- Installed
iSeries Access ODBC Driver -- Installed
SQL Server Native Client 10.0 -- Installed
**Oracle in OraClient11g_home1 -- Installed**
IBM DB2 ODBC DRIVER - DB2_976_64 -- Installed
IBM DB2 ODBC DRIVER -- Installed
ODBC Driver 11 for SQL Server -- Installed
DataDirect 6.1 Sybase Wire Protocol -- Installed
SQL Server Native Client 11.0 -- Installed
TNS_ADMIN=C:\WINDOWS\TNS
ORACLE_HOME=
------------------------------------------------

我想知道如何分别列出安装的是32位驱动还是64位Oracle驱动。我的机器上都有,但没有说明是哪一个。据推测,我认为这可能意味着两者或其中之一。通常,如果找到 32 位驱动程序,我希望在名称中看到“32”。

此外,我很想知道在注册表中哪里可以最好地查看此信息。

oracle vbscript
1个回答
4
投票

根据您的 VBS 代码,问题应该是:Using VBS and the registry to determine which version and 32 vs. 64 bit of ODBC drivers are installed

还有许多其他驱动程序可用于 Oracle,例如OleDB、ODP.NET、JDBC 等

为了获得 32 位和 64 位,您可以通过两种方式进行

在不同的脚本主机上运行 VBS,即

For 64 Bit: >c:\Windows\system32\cscript.exe Drivers.vbs
For 32 Bit: >c:\Windows\SysWOW64\cscript.exe Drivers.vbs

或修改 VBS 脚本以查询注册表中的 32 位和 64 位路径:

strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes

For i = 0 to UBound(arrValueNames)
    strValueName = arrValueNames(i)
    objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue    
    Wscript.Echo arrValueNames(i) & " -- 64 Bit " & strValue
Next

strKeyPath = "SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers"
objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes

For i = 0 to UBound(arrValueNames)
    strValueName = arrValueNames(i)
    objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue    
    Wscript.Echo arrValueNames(i) & " -- 32 Bit " & strValue
Next

另一个注意事项:

TNS_ADMIN
ORACLE_HOME
可以通过环境变量定义,但是您也可以在注册表中定义它们。检查 64 位

HKLM\SOFTWARE\ORACLE\Key_{ORACLE_HOME_NAME}\TNS_ADMIN 
and 
HKLM\SOFTWARE\ORACLE\Key_{ORACLE_HOME_NAME}\ORACLE_HOME

和 32 位

HKLM\SOFTWARE\Wow6432Node\ORACLE\Key_{ORACLE_HOME_NAME}\TNS_ADMIN
and
HKLM\SOFTWARE\Wow6432Node\ORACLE\Key_{ORACLE_HOME_NAME}\ORACLE_HOME
© www.soinside.com 2019 - 2024. All rights reserved.