Sign in to follow this  
Followers 0
gfunkpilot

COM+ application component update

13 posts in this topic

Hello, 

I am a bit new to manipulating COM+ stuff.  I am able to get the Identity for the application set correctly, however, I am trying to update the Object Pooling option for the COM+ application component.  Here is my code snippet for retrieving the COM+ class, the application (retrieval and updating the identity) and attempting the component retrieval and updating.  However, the $Components variable is empty, so for some reason I am not finding the component data properly.  

Note: I did change the actual names of the application and component since the are proprietary applications and I didn't want to get into trouble.  

Any help is greatly appreciated!

$oCatalog = ObjCreate("COMAdmin.COMAdminCatalog.1")
    If IsObj($oCatalog) Then
        $Applications = $oCatalog.GetCollection("Applications")
        $Applications.Populate
        For $app in $Applications
            $appName = $app.Value("Name")
            If StringInStr($appName, "ApplicationName", 0) Then
                _FileWriteLog(@ScriptDir & "\Logs\FAS_Config.log", "Setting Identity = " & $ID & " for COM+ application ""ApplicationName""")
                $app.Value("Identity") = $ID
                $app.Value("Password") = $PW
                $Applications.SaveChanges
                MsgBox(0, "appName", $appName) ;debug line, this does retrieve the correct application.
                MsgBox(0, "app.Key", $app.Key) ;debug line, this is the correct GUID.
                    
                $Components = $Applications.GetCollection("Components", $app.Key) ;;;$Components results in empty string for some reason
                $Components.Populate
                MsgBox(0, "component populated?", $Components) ;debug line
                If StringLen($Components) > 0 Then
                    MsgBox(0, "Components are populated", $Components) ;debug line
                    For $comp in $Components
                        MsgBox(0, "Each Component", $comp) ;debug line
                        $compName = $comp.Value("Name")
                        If StringInStr($compName, "ComponentName", 0) Then
                            $comp.Value("ObjectPoolingEnabled") = 1
                            $comp.Value("MaxPoolSize") = $CPUcount * 2
                            $comp.Value("MinPoolSize") = $CPUcount * 2
                            $comp.Value("IISIntrinsics") = 1
                            MsgBox(0, "My Component", $compName) ;debug line
                            $Components.SaveChanges
                        EndIf
                    Next
                Else
                    MsgBox(0, "Component Error", "No components found for application!")
                EndIf

            EndIf
        Next


        _deleteTMPfiles()
    Else
        Msgbox(0,"Error","Failed to connect to COM+ catalog." & @CRLF & "Please verify you have access to COM+ settings.  Exiting!")
        _FileWriteLog(@ScriptDir & "\Logs\FAS_Config.log", "Failed to connect to COM+ catalog.  Please verify you have access to COM+ settings.  Exiting!")
        _deleteTMPfiles()
    EndIf

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Oh, crud, I forgot to include that part.

I wrote this script using 3.3.6.1, but this morning I upgraded to 3.3.12.0 and recompiled but still have the same results.

Thanks!

Share this post


Link to post
Share on other sites

To get better error information you could add this lines at the top of your script:

#include <Debug.au3>
_DebugSetup()
_DebugCOMError()

What do you get then?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The debug report only shows this:

>>>>>> Please close the "Report Log Window" to exit <<<<<<<

Share this post


Link to post
Share on other sites

So there are no COM errors.

What type is $Components supposed to be (according to the documentation)? I would assume a collection. So you can't check for a string.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

In this case I would replace

If StringLen($Components) > 0 Then

with

If $Components.Count > 0 Then

if the collection offers the count property.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Well, either the collection doesn't offer the count property or it is reporting > 0, cause I made it past the If statement to the 

MsgBox(0, "Components are populated", $Components) ;debug line
For $comp in $Components
MsgBox(0, "Each Component", $comp) ;debug line

and from there it tries to complete the value setting and errors with exception occurred due to the empty string for $comp.

Edited by gfunkpilot

Share this post


Link to post
Share on other sites

If the debug statements I posted above are still present in your script then there is a count property available. Else you would see a COM error emssage.

For $comp in $Components

doesn't return a string but an object of the collection.

What's the exact error message you get?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I took out my other error capturing function and this is the error I am seeing now:

@@ DEBUG COM Error encountered in COMupdate.exe (-1) :
Number         = 0x80020009 (-2147352567)
WinDescription = Exception occurred.
Description  
Source        
HelpFile      
HelpContext   = 0
LastDllError   = 0
Retcode       = 0x80070057
>>>>>> Please close the "Report Log Window" to exit <<<<<<<
 
I am logged in as Administrator, so it is not a permissions issue.  However, it very well could be I have the wrong catalog for the components, but I am not sure what the catalog it would be if not this one.

Share this post


Link to post
Share on other sites

After doing some more testing, I think the catalog is correct.  I changed the code to look at one of the "default" COM+ applications named 'COM+ Utilities'.  This change still returns blank entries, however, when I get to the individual component loop

For $comp in $Components
    MsgBox(0, "Each Component", $comp.Value("Name")) ;debug line

I receive a popup titled "Each Component" with the value field blank five times and there are five components for the 'COM+ Utilities' application.  Therefore, it seems to be finding the components, but I guess I am not "looking" for the correct value to display?  Any one have any thoughts on where I could be missing something?

Share this post


Link to post
Share on other sites

I figured it out.  The components have different naming conventions than the applications group.  The value to find the "name" of the component is "ProgID" and not "Name" like the applications group.  Therefore, my code changes to this:

For $comp in $Components
    $compName = $comp.Value("ProgID")
    MsgBox(0, "Each Component", $compName) ;debug line

Hope this helps other people in the future.

Thanks for the help!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0