Verify the status of an Web Directory Application using WMI

Here is a code snippet which is used to verify the status of an Web Directory Application using WMI, without opening IIS Manager. 

strComputer = "."
Set objWMIService = GetObject("winmgmts:{authenticationLevel=pktPrivacy}\\" & strComputer & "\root\microsoftiisv2")
Set colItems = objWMIService.ExecQuery("Select * From IIsWebDirectory Where Name = " & "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
strStatus = objItem.AppGetStatus
If strStatus = 2 Then
Wscript.Echo "The application is running."
ElseIf strStatus = 3 Then
Wscript.Echo "The application is stopped."
Else
Wscript.Echo "The status could not be determined."
End If
Next

Supported Platform: Windows Server 2003