Windows – Component services, running processes, scheduled recycle

dcomwindowswindows-sbs-2003

I've got a Windows Server 2003 SBS SP2 box.

It's hosting our business application.

About once a week the clients for the application on work stations throughout the office get so they receive an "Unable to contact business server" error message.

At this point I remote to the SBS

run "dcomcnfg" Console Root > Component Services > Computers > My Computer > Running Processes.

In there, I right click the icon for the application and run a recycle. As soon as this process has completed my clients can communicate with the server again.

My question is, can this be automated to be recycled once a day? Do I need to do it via the command line and write a batch script to do this? If this is the case what are the command line statements?

If it can be done in the GUI somewhere can you point me in the right direction?

Best Answer

You can use PowerShell to interact with the Component Services catalog and set the "RecycleLifetimeLimit" value to the number of minutes the application should run before recycling:

$TargetAppName = "todbannersBiznezApp"

$ComCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$ComCatalog.Connect("localhost")

$ComApps = $ComCatalog.GetCollection("Applications")
$ComApps.Populate()

foreach($App in $ComApps)
{
    if($App.Name -eq $TargetAppName)
    {
        # 30240 (21 days) is the maximum lifetime value
        # Let's set it to 1440 (24 hours) 
        $App.Value("RecycleLifetimeLimit") = 1440
        $ComApps.SaveChanges()
        break
    }
}

You can also do it from the Component Services management console if you like:

  1. Open the Component Services management console (run -> comexp.msc)
  2. Go to Component Services -> Computers -> My Computer/Localhost
  3. Expand COM+ Applications
  4. Right-click your business application and select Properties
  5. Switch to the "Pooling and Recycling" tab
  6. Configure the desired recycle settings for the app