使用 VBS 和注册表来确定安装了哪个版本和 32 位

Using VBS and the registry to determine which version and 32 vs. 64 bit oracle drivers are installed(使用 VBS 和注册表来确定安装了哪个版本和 32 位与 64 位的 oracle 驱动程序)
本文介绍了使用 VBS 和注册表来确定安装了哪个版本和 32 位与 64 位的 oracle 驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'd like to use VBS to read the registry to list some info on a server including the drivers. 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".你能帮我吗?谢谢!

Question I'd like to know how to seperately list if the 32 bit driver or the 64 bit Oracle driver is installed. I have both on my machine, but it doesn't indicate which. Presumably, it can mean both or either, I assume. Normally, if a 32 bit driver were found, I'd expect to see "32" in the name. Can you help? Thank you!

如果您知道最好在注册表中的哪个位置查找此信息,如果您不知道代码,这也会很有帮助.

if you know where to best look in the registry for this info, that would be helpful, too, if you don't know the code off hand.

推荐答案

根据您的 VBS 代码,问题应该是:使用 VBS 和注册表来确定 ODBC 的版本和 32 位与 64 位 驱动程序已安装

According to your VBS code the question should be: Using VBS and the registry to determine which version and 32 vs. 64 bit of ODBC drivers are installed

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

There are many other drivers available for Oracle, e.g. OleDB, ODP.NET, JDBC, etc.

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

In order to get 32 and 64 bit you can do it in two ways

要么在不同的脚本宿主中运行VBS,即

Either run the VBS in different scripting host, i.e.

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

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

Or modify the VBS script in order to interrogate 32 and 64 Bit path in Registry:

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_ADMINORACLE_HOME 可以通过环境变量定义,但是您也可以在注册表中定义它们.检查 64 位

Another note: TNS_ADMINand ORACLE_HOME can be defined by environment variable, however you can defined them also in the Registry. Check for 64 bit

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

这篇关于使用 VBS 和注册表来确定安装了哪个版本和 32 位与 64 位的 oracle 驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)