Office 2007 WMI Scripting

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ayth
Posts: 10
Last visit: Mon Nov 26, 2007 8:51 pm

Office 2007 WMI Scripting

Post by ayth »

Hello,

Has anyone done any scripting with Office 2007? My situation is that one of our clients is a law firm, which utilizes a lot of com add-ins and templates in Microsoft Word.

Our problem is that the add-ins/templates are constantly getting disabled within Word. I was tasked to see if it's possible to re-enable the add-ins/templates via scripting, or at least identify if their are any.

So I started exploring WMI. First using WMI security, I noticed their is a namespace called MSAPPS12, 12 being the version of Office 2007. Then using Primalscript's WMI Wizard I started enumerating the properties of different classes to see what I can find. However, the script was bringing back nothing, nothing was being echo'd to the window. So I removed the "On Error Resume Next" that is put in and now I get back the following error:

Script: Myscript.vbs
Line: 17
Char: 1
Error: 0x80041013
Code: 80041013
Source: (null)

It seems that there are no valid, or populating values for the properties. I've googled WMI Scripting Office 2007, in different variations but have no luck. Here is my script, which is just an exact copy of generated from WMI Wizard:

'On Error Resume NextDim strComputerDim objWMIServiceDim propValueDim objItemDim SWBemlocatorDim UserNameDim PasswordDim colItems
strComputer = "."UserName = ""Password = ""Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")Set objWMIService = SWBemlocator.ConnectServer(strComputer,"rootmsapps12",UserName,Password)Set colItems = objWMIService.ExecQuery("Select * from Win32_Word12Template",,48)For Each objItem in colItems WScript.Echo "Name: " & objItem.Name WScript.Echo "Path: " & objItem.Path WScript.Echo "Type: " & objItem.TypeNext
If anyone has any ideas that would be great. Thanks.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Office 2007 WMI Scripting

Post by jvierra »

Here is another that should work:

You need to change the MSAPPS11 to MSAPPS12

Code: Select all

	
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & strComputer   & "rootMSApps11")
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_OutlookCOMAddin")
For Each strSetting in colSettings
    Wscript.Echo "GUID: " & strSetting.GUID
    Wscript.Echo "Path: " & strSetting.Path
    Wscript.Echo "Name: " & strSetting.Name
    Wscript.Echo "Installed: " & strSetting.Installed
    Wscript.Echo
Next
This topic is 15 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked