locked
Manage Outlook Add-Ins Programatically RRS feed

  • Question

  • We publish Outlook in a Citrix XenApp environment. The installation is shared by users with different needs. One of our departments would like to make use of a vendor supplied Outlook Add-In, but that add-in is only relevant to members of that department, and in fact will cause grief for non members as they will be prompted to log in to a system to which they have no access. I can enable or disable the add-in in question by manually going in to Outlook "Tools>Trust Center>Add-ins>Manage COM Add-ins" by simply checking or unchecking a box. What I need to figure out is how to do this programatically by script (or possibly GPO) so that the add-in is enabled for members of the department in question and disabled for everyone else. So far I have had no luck. I have compared the HKCU registry hive with the Add-In enabled and Disabled. There is one key that changes consistently when I do so, but changing that key programatically does not cause the add-in to become either enabled or disabled. What happens when I check or uncheck the box? Where is that information stored? How can I manipulate it?
    Thursday, February 3, 2011 10:37 PM

Answers

  • LoadBehavior only has an effect before Outlook is started. Changing it to 2 will set it to load on demand, to 3 is load on startup, 0 is don't show it. There are other settings but those are the important ones.
     
    Outlook.Application.ComAddins.Item(<addinProgId>).Connect can be set to False to disconnect the addin after Outlook startup, where <addinProgId>.is the ProgID for the addin.
     
    You can iterate the ComAddins collection to find the correct ProgId string to use in a script. The ProgId property is exposed in the Office.ComAddins.ComAddin object.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Eric P" <=?utf-8?B?RXJpYyBQ?=> wrote in message news:5a5c3097-10ca-4ee0-805f-dfa124020818...
    We publish Outlook in a Citrix XenApp environment. The installation is shared by users with different needs. One of our departments would like to make use of a vendor supplied Outlook Add-In, but that add-in is only relevant to members of that department, and in fact will cause grief for non members as they will be prompted to log in to a system to which they have no access. I can enable or disable the add-in in question by manually going in to Outlook "Tools>Trust Center>Add-ins>Manage COM Add-ins" by simply checking or unchecking a box. What I need to figure out is how to do this programatically by script (or possibly GPO) so that the add-in is enabled for members of the department in question and disabled for everyone else. So far I have had no luck. I have compared the HKCU registry hive with the Add-In enabled and Disabled. There is one key that changes consistently when I do so, but changing that key programatically does not cause the add-in to become either enabled or disabled. What happens when I check or uncheck the box? Where is that information stored? How can I manipulate it?

    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Thursday, February 10, 2011 3:50 AM
    Thursday, February 3, 2011 11:37 PM

All replies

  • LoadBehavior only has an effect before Outlook is started. Changing it to 2 will set it to load on demand, to 3 is load on startup, 0 is don't show it. There are other settings but those are the important ones.
     
    Outlook.Application.ComAddins.Item(<addinProgId>).Connect can be set to False to disconnect the addin after Outlook startup, where <addinProgId>.is the ProgID for the addin.
     
    You can iterate the ComAddins collection to find the correct ProgId string to use in a script. The ProgId property is exposed in the Office.ComAddins.ComAddin object.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Eric P" <=?utf-8?B?RXJpYyBQ?=> wrote in message news:5a5c3097-10ca-4ee0-805f-dfa124020818...
    We publish Outlook in a Citrix XenApp environment. The installation is shared by users with different needs. One of our departments would like to make use of a vendor supplied Outlook Add-In, but that add-in is only relevant to members of that department, and in fact will cause grief for non members as they will be prompted to log in to a system to which they have no access. I can enable or disable the add-in in question by manually going in to Outlook "Tools>Trust Center>Add-ins>Manage COM Add-ins" by simply checking or unchecking a box. What I need to figure out is how to do this programatically by script (or possibly GPO) so that the add-in is enabled for members of the department in question and disabled for everyone else. So far I have had no luck. I have compared the HKCU registry hive with the Add-In enabled and Disabled. There is one key that changes consistently when I do so, but changing that key programatically does not cause the add-in to become either enabled or disabled. What happens when I check or uncheck the box? Where is that information stored? How can I manipulate it?

    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Thursday, February 10, 2011 3:50 AM
    Thursday, February 3, 2011 11:37 PM
  • THANK YOU!

    I wanted to add how I did this soup to nuts since I'm a bit fresh at c# and found myself spending too much time figuring out the details.  It's too bad MS made it so difficult to turn off add-ins because we don't need many of them and they slow outlook startup down.  I wanted to turn them all off for every user in the company.  Then I found I do need one for voicemail... Anyway here is the code (c#)

    First add referances to your solution: Microsoft.Office.Interop.Outlook and Microsoft.Office.Core

    To get a list of all the add-in program ids:

    using System;
    using Microsoft.Office.Core;
    using Microsoft.Office.Interop.Outlook;

    namespace add_in_Killer
    {
        class Program
        {
            static void Main(string[] args)
            {
                Application OutLook = new Application();
                foreach(COMAddIn addin in  OutLook.Application.COMAddIns)
                {
                    Console.WriteLine(addin.ProgId);
                }
                Console.ReadKey();
            }
         }
    }

    You could just kill them all at the foreach loop. Warning: If the Add-in is already disabled the program trips.

                if(OutLook.Application.COMAddIns.Item(addin.ProgId).Connect == true)
                    OutLook.Application.COMAddIns.Item(addin.ProgId).Connect = false;

    Or you can pick the IDs you want to kill and set them to false. 

    here is how to turn off the social connector (program id = OscAddin.Connect)

    using System;
    using Microsoft.Office.Core;
    using Microsoft.Office.Interop.Outlook;

    namespace add_in_Killer
    {
        class Program
        {
            static void Main(string[] args)
            {
                Application OutLook = new Application();
                if(OutLook.Application.COMAddIns.Item("OscAddin.Connect").Connect == true)
                    OutLook.Application.COMAddIns.Item("OscAddin.Connect").Connect = false;
             }
         }
    }

     

    Wednesday, July 6, 2011 5:26 PM
  • Hi Fred,

    I have used above solution and it is working fine only if i open outlook as admin.

    For normal user, it is not working.

    It is giving me below error.

    system.runtime.interop.services.comexception (0x800040005) this add-in is installed for all users on this computer and can only be conneced or disconnected by an administrator)

    Thursday, January 8, 2015 9:00 AM
  • Hi Ken.

    Where i will write these code as it has to be execute everytime user opens outlook.

    Thanks,

    Kabita

    Thursday, March 3, 2016 1:57 PM
  • This would only work for addins registered for current user, in HKCU. It wouldn't work unless Outlook is started as administrator for addins registered for all users in HKLM.

    One place the code can be run is from a COM addin. An alternative would be a startup macro in the Outlook VBA session's ThisOutlookSession code module, in the Application.Startup() event handler.


    Ken Slovak MVP - Outlook

    Thursday, March 3, 2016 2:22 PM
  • You can also disable an addin from the Windows login script.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, March 3, 2016 3:12 PM
  • Yeah, in that case you would probably want to set the LoadBehavior value in the registry for the addin to 2 or 0 to prevent it from loading.

    Ken Slovak MVP - Outlook

    Thursday, March 3, 2016 3:38 PM