Where can I find all of the COM objects that can b

2019-01-08 08:56发布

问题:

In Powershell I can create COM objects which can be used, for example, to control Microsoft Office applications:

$excel = New-Object -com "Excel.Application"
$excel.visible = $true

How can I list all of the available COM objects that can be created in Powershell?

回答1:

I found this powershell one-liner script that supposedly lists all COM objects.

gci HKLM:\Software\Classes -ea 0| ? {$_.PSChildName -match '^\w+\.\w+$' -and
(gp "$($_.PSPath)\CLSID" -ea 0)} | ft PSChildName

let us know if it works!



回答2:

Use OleView.exe from Microsoft. I think it may come with Visual Studio. If not, you can find it in the Windows SDK. That's a big download; you can either download the whole thing or you could experiment with downloading it piecemeal using the setup.exe installer.

Once in OleView, look under "type libraries". Excel for instance appears under "Microsoft Exel".



回答3:

Another option that should be noted is through WMI:

Get-WMIObject Win32_ClassicCOMClassSetting