問題描述
我想使用 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_ADMIN
和 ORACLE_HOME
可以通過環境變量定義,但是您也可以在注冊表中定義它們.檢查 64 位
Another note: TNS_ADMIN
and 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 驅動程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!