Question: Is it possible to programmaticaly configure COM+ service.

I need to do the following using C# or any script

1. Open Administrative Tools -> Component Services
2. Expand Components Services -> My Computer -> COM+ Applications
3. Right Click HyperV Environment Manager(COM+ service name) andselect Properties.
4. Click on Pooling & Recycling tab
5. Under Application recycling, set Memory Limit(KB) value to 262144.
6. Click OK
7. Right Click HyperV Environment Manager(COM+ service name) and select ShutDown
8. Right Click HyperV Environment Manager(COM+ service name) and select Start

It will be great if you could guide me or send me the code snippet.

Thanks in advance.

Regards,
Sreejith Rajan

Answer: 
You can use [Component Services Administration (COMAdmin) Library](http://msdn.microsoft.com/en-us/library/windows/desktop/ms688248.aspx) to programmatically accomplish the steps you outlined. One can access it from C#, VBScript, PowerShell, anything else that can harness the power of COM components.

VB6 code sample on [Configuring COM+ Application Recycling Values](http://msdn.microsoft.com/en-us/library/windows/desktop/ms684192.aspx) MSDN page addresses exactly your need to configure Recycling properties. Check [Setting application recycling settings for COM+ component from code / command line](https://stackoverflow.com/questions/16300144/setting-application-recycling-settings-for-com-component-from-code-command-li/16384616#16384616) question for VBScript port of MSDN sample.

By the way, you do not have to restart target COM+ application for changes to take effect. I.e. the last two steps in your routine are redundant:

```none
 7. Right Click HyperV Environment Manager(COM+ service name) and select ShutDown
 8. Right Click HyperV Environment Manager(COM+ service name) and select Start

```
You should use [HyperV's WMI](http://msdn.microsoft.com/en-us/library/cc136992%28VS.85%29.aspx) to do this. There are many examples on the web, such as [this one](http://social.msdn.microsoft.com/Forums/en/servervirtualization/thread/9326f50f-a3e8-4190-8319-740bfa2af71e).