2016-06-16 11 views
5

माइक्रोसॉफ्ट एक्सेल "अन्य स्रोतों" से डेटा के आयात की अनुमति देता है। विकल्पों में से एक ओएलई डीबी प्रदाता का उपयोग करना है।स्थापित ओएलई डीबी प्रदाताओं की सूची कैसे प्राप्त करें?

उपलब्ध ओएलई डीबी प्रदाताओं की सूची कैसे प्राप्त करें?

उत्तर

6

मैं अपने स्वयं के प्रश्न का उत्तर दे रहा हूं क्योंकि मुझे यह उम्मीद करना मुश्किल था कि मुझे उम्मीद थी। Google-fu केवल मेरे प्रश्न का उत्तर दे सकता है; मुझे विभिन्न ब्लॉग प्रविष्टियों और आधिकारिक दस्तावेज से जानकारी संश्लेषित करने की आवश्यकता थी।

नीचे वीबीस्क्रिप्ट है, आप एक टेक्स्ट फ़ाइल में कॉपी/पेस्ट कर सकते हैं और विंडोज पर चल सकते हैं। इस संस्करण को चलाने के लिए आपको स्थानीय व्यवस्थापक अधिकारों की आवश्यकता नहीं है।

आपके सीपीयू पर आपकी रजिस्ट्री और गति के आकार के आधार पर, इसे चलाने में एक मिनट तक लग सकते हैं। नतीजा टेक्स्ट के साथ एक संदेश बॉक्स है जिसे Ctrl+C के साथ क्लिपबोर्ड पर कॉपी किया जा सकता है।

प्राथमिक संदर्भ: https://sysmod.wordpress.com/2014/07/11/vbscript-to-list-installed-oledb-providers/

'List of installed OLEDB providers on local computer 
Option Explicit 
Const HKEY_CLASSES_ROOT  = &H80000000 
Const HKEY_CURRENT_USER  = &H80000001 
Const HKEY_LOCAL_MACHINE = &H80000002 
Const HKEY_USERS  = &H80000003 
Const HKEY_CURRENT_CONFIG = &H80000005 

Dim OutText, strComputer, objRegistry 
Dim num 
Dim ProgIdDict 

strComputer = "." 
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") 
OutText = "Note: Strike Ctrl+C to copy full text to clipboard" 
Num = 1 
Set ProgIdDict = CreateObject("Scripting.Dictionary") 

' I discovered these registrations can appear in three different places. 
' Use ProgIdDict to prevent dupes in the output 
Append objRegistry, HKEY_CLASSES_ROOT, "HKEY_CLASSES_ROOT", "CLSID", ProgIdDict, Num, OutText 
Append objRegistry, HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE", "SOFTWARE\Classes\CLSID", ProgIdDict, Num, OutText 
Append objRegistry, HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE", "SOFTWARE\Classes\Wow6432Node\CLSID", ProgIdDict, Num, OutText 

Sub Append(ByVal objRegistry, ByVal HKEYConstant, ByVal HKEYConstantStr, ByVal KeyPrefixStr, ByVal ProgIdDict, ByRef Num, ByRef OutText) 

    Dim Key, arrKeys 
    Dim strKeyPath, strValue, uValue 

    objRegistry.enumKey HKEYConstant, KeyPrefixStr, arrKeys 

    for each key in arrKeys 

     strKeyPath = KeyPrefixStr & "\" & key 

     ' if key exists... 
     ' I noticed something weird where non-MSOLAP entries use the first style, 
     ' and MSOLAP entries use the second style. 
     If 0 = objRegistry.GetDWordValue(HKEYConstant, strKeyPath, "OLEDB_SERVICES", uValue) _ 
     Or 0 = objRegistry.GetDWordValue(HKEYConstant, strKeyPath & "\OLEDB_SERVICES", "", uValue) _ 
     Then 
      objRegistry.GetStringValue HKEYConstant,strKeyPath & "\ProgID","",strValue 
      If Not ProgIdDict.Exists(strValue) _ 
      Then 
       ProgIdDict.Add strValue, strValue 
       OutText=OutText & vbcrlf & vbcrlf 
       'get the (Default) value which is the name of the provider 
       objRegistry.GetStringValue HKEYConstant,strKeyPath,"",strValue 
       OutText=OutText & num & ") " & strValue & vbcrlf & "Key: \\" & HKEYConstantStr & "\" & KeyPrefixStr & "\" & key 
       ' and the expanded description 
       objRegistry.GetStringValue HKEYConstant,strKeyPath & "\OLE DB Provider","",strValue 
       OutText=OutText & vbcrlf & "OLE DB Provider: " & strValue 
       objRegistry.GetStringValue HKEYConstant,strKeyPath & "\ProgID","",strValue 
       OutText=OutText & vbcrlf & "ProgID: " & strValue 
       objRegistry.GetStringValue HKEYConstant,strKeyPath & "\VersionIndependentProgID","",strValue 
       OutText=OutText & vbcrlf & "VersionIndependentProgID: " & strValue 
       num = 1 + num 
      End If 
     end if 
    next 

End Sub 

Wscript.Echo OutText 
2

आप powershell उपलब्ध है, तो सिर्फ एक powershell कमांड प्रॉम्प्ट पर पेस्ट करें:

foreach ($provider in [System.Data.OleDb.OleDbEnumerator]::GetRootEnumerator()) 
{ 
    $v = New-Object PSObject   
    for ($i = 0; $i -lt $provider.FieldCount; $i++) 
    { 
     Add-Member -in $v NoteProperty $provider.GetName($i) $provider.GetValue($i) 
    } 
    $v 
} 

क्रेडिट और अधिक उन्नत उपयोग: http://dbadailystuff.com/list-all-ole-db-providers-in-powershell

संबंधित मुद्दे