'Description:
' Function to get the IIsApplicationPools Object.
'Input:
' None.
'Output:
' An IIsApplicationPools Object.
'Throw Exception When:
' Cannot Get IIsApplicationPools Object.
public function get_IIS_Pools
on error resume next
set get_IIS_Pools = GetObject("IIS://localhost/W3SVC/AppPools")
if (Err.Number <> 0) Then
on error go to 0
Err.Raise 10000, "get_IIS_Pools", "Unable get the IISApplicationPools object"
else
on error go to 0
end if
end function
If you can not understand above code sample, please refer to another article Quick Start : IIS | Minicoder
If you want get specific IISApplicationPool object using the name of the application pool instead of IISApplicationPools, Please see
'Description:
' Function to get the IIsApplicationPool Object using the name of the application pool.
'Input:
' appPoolName: the name of the application pool
'Output:
' A IIsApplicationPool Object with the given name.
'Throw Exception When:
' Cannot get IIsApplicationPool Object of the specified application pool.
public function get_IIS_Pool(appPoolName)
on error resume next
set get_IIS_Pool = GetObject("IIS://localhost/W3SVC/AppPools/" & appPoolName)
if (Err.Number <> 0) Then
on error goto 0
Err.Raise 10000, "get_IIS_Pool", "Unable get IISApplicationPool object by using application pool name" & appPoolName
else
on error goto 0
end if
end function
You can also use above code to check the existence of application pool with given name
'Description:
' Function to Check the existence of the application pool with the given name.
'Input:
' appPoolName: the name of the application pool
'Output:
' Exist -> True.
' Non-exist -> False.
'Throw Exception When:
' Never.
public function check_IIS_Pool(appPoolName)
on error resume next
get_IIS_Pool(appPoolName)
if (Err.Number <> 0) then
check_IIS_Pool = false
else
check_IIS_Pool = true
end if
on error goto 0
end function