buymeapc Posted November 28, 2011 Share Posted November 28, 2011 (edited) Hi all,I'm looking to get a list of the application pools and the virtual directories (applications) that are within each pool listed out into an array from IIS7. I'm having no luck with the WMI code I've found online. I don't really want to use "appcmd.exe" either since I also need to find some properties of the applciation pools as well, such as:Periodic Restart RequestsPeriodic Restart TimeIdle TimeoutApp Pool Queue LengthEtc...Here's the code I have thus far and it seems to be bailing on the InstancesOf command and not returning any results. What could I be missing? Thanks for the help. ;AppPool Enum Dim $oWebAdmin, $oApps, $oApp $oWebAdmin = ObjGet("winmgmts:rootWebAdministration") If IsObj($oWebAdmin) = 0 Then MsgBox(0, "", "Not an object") Exit EndIf $oApps = $oWebAdmin.InstancesOf("Application") For $oApp In $oApps MsgBox(0, $oApp.SiteName, "Web site/Application: " & $oApp.SiteName & $oApp.Path &@CRLF&"Application Pool: " & $oApp.ApplicationPool &@CRLF&"Enabled protocol(s): " & $oApp.EnabledProtocols) Next Edited November 28, 2011 by buymeapc Link to comment Share on other sites More sharing options...
water Posted November 28, 2011 Share Posted November 28, 2011 I would suggest to implement an COM error handler. Please have a look at ObjEvent in the help file. Split the MsgBox statement so that each property is displayed separately. If you get an error message you see exactly which property causes the problem. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler ; Your code goes here Exit ; This is my custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
buymeapc Posted November 28, 2011 Author Share Posted November 28, 2011 (edited) Thanks for the help! Here's the response I'm receiving after I added the error handler you suggested (image attached). After doing a quick Google search, I found this website http://www.computerperformance.co.uk/Logon/code/code_80041013.htm and I followed what it said even though it sounded a bit weird. Still no luck, though. Edited November 28, 2011 by buymeapc Link to comment Share on other sites More sharing options...
water Posted November 28, 2011 Share Posted November 28, 2011 The error code 0x80041013 you get means: "WBEM_E_PROVIDER_LOAD_FAILURE". According to Microsoft this could be on of the following problems:COM cannot locate a provider referenced in the schema.This error may be caused by many conditions, including the following:Provider is using a WMI DLL that does not match the .lib file used when the provider was built.Provider's DLL, or any of the DLLs on which it depends, is corrupt.Provider failed to export DllRegisterServer.In-process provider was not registered using the regsvr32 command.Out-of-process provider was not registered using the /regserver switch. For example, myprog.exe /regserver.WMI might not be running on the web server? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
buymeapc Posted November 29, 2011 Author Share Posted November 29, 2011 After checking all the advanced things, I had one of those "DUH " moments. I realized UAC is enabed...it disables WMI calls unless the applciation is run with elevated permissions. As soon as I ran this "as administrator", even though I'm already an admin, everything worked perfectly. Thanks for your help! Link to comment Share on other sites More sharing options...
buymeapc Posted November 30, 2011 Author Share Posted November 30, 2011 Ok, now I'm trying to get the periodic restart schedule for the application pools in IIS7. The code I have doesn't quite work though. Could anyone tell me what I might be missing? Thanks! $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler Dim $oWebAdmin, $oApps, $oApp $oWebAdmin = ObjGet("winmgmts:root\WebAdministration") If IsObj($oWebAdmin) = 0 Then MsgBox(0, "", "Not an object") Exit EndIf $oApps = $oWebAdmin.InstancesOf("Application") For $oApp In $oApps $schedText = "" For $sched In $oApp.Recycling.PeriodicRestart.Schedule For $vProp In $sched.Properties $schedText &= $vProp.Value Next Next MsgBox(0, "", $schedText) ;MsgBox(0, $oApp.ApplicationPool, $oApp.ApplicationPool.Recycling.PeriodicRestart.Schedule) ;MsgBox(0, $oApp.SiteName, "Web site/Application: " & $oApp.SiteName & $oApp.Path &@CRLF&"Application Pool: " & $oApp.ApplicationPool &@CRLF&"Enabled protocol(s): " & $oApp.EnabledProtocols);&@CRLF&"Idle TimeOut: "&$oApp.ProcessModel.IdleTimeout) Next Exit ; This is my custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc Link to comment Share on other sites More sharing options...
buymeapc Posted November 30, 2011 Author Share Posted November 30, 2011 (edited) Figured it out. Needed to change: $oApps = $oWebAdmin.InstancesOf("Application") To $oApps = $oWebAdmin.InstancesOf("ApplicationPool") Edited November 30, 2011 by buymeapc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now