L
Lou Civitella
I have found code that Recycles the Application Pool but it was written in
VBScript can anyone convert this for me to VB.Net?
Thanks!
'Appendix B: Application Pool Recycle script - Save as Recycleap.vbs
'By Default Recycle All App Pools
bRecycleAll = 1
'Delay between each apppool recycle in seconds (if all apppools are being
recycled)
iRecycleDelay = 5
If Wscript.arguments.count = 0 Then
WScript.Echo "Syntax: recycleap server [AppPoolName]"
WScript.Echo
WScript.Echo "Example: recycleap servername DefaultAppPool"
WScript.Quit (0)
Else
strServer = WScript.arguments(0)
If WScript.arguments.count > 1 Then
strAppPoolName = WScript.arguments(1)
bRecycleAll = 0
End If
End If
'Connect to the specified server using WMI
set Locator = CreateObject("WbemScripting.SWbemLocator")
Locator.Security_.AuthenticationLevel = 6
set Service = locator.connectserver(strServer,"root/MicrosoftIISv2")
'Get a collection of WMI apppools
set APCollection = Service.InstancesOf("IISApplicationPool")
If bRecycleAll = 1 Then
'Recycle each apppool returned in the collection with a delay of
iRecycleDelay
For each APInstance in APCollection
WScript.Echo "Recycling " & strServer & "/" & APInstance.Name
APInstance.Recycle
WScript.Echo "Waiting " & iRecycleDelay & " seconds..."
Wscript.Sleep(iRecycleDelay*1000)
Next
Else
'If we're not recycling all apppools find the one that was specified and
recycle it
For each APInstance in APCollection
If UCase(ApInstance.Name) = UCase("W3SVC/AppPools/" &
strAppPoolName) Then
WScript.Echo "Recycling " & strServer & "/" & APInstance.Name
APInstance.Recycle
End If
Next
End If
WScript.Echo "Done!"
VBScript can anyone convert this for me to VB.Net?
Thanks!
'Appendix B: Application Pool Recycle script - Save as Recycleap.vbs
'By Default Recycle All App Pools
bRecycleAll = 1
'Delay between each apppool recycle in seconds (if all apppools are being
recycled)
iRecycleDelay = 5
If Wscript.arguments.count = 0 Then
WScript.Echo "Syntax: recycleap server [AppPoolName]"
WScript.Echo
WScript.Echo "Example: recycleap servername DefaultAppPool"
WScript.Quit (0)
Else
strServer = WScript.arguments(0)
If WScript.arguments.count > 1 Then
strAppPoolName = WScript.arguments(1)
bRecycleAll = 0
End If
End If
'Connect to the specified server using WMI
set Locator = CreateObject("WbemScripting.SWbemLocator")
Locator.Security_.AuthenticationLevel = 6
set Service = locator.connectserver(strServer,"root/MicrosoftIISv2")
'Get a collection of WMI apppools
set APCollection = Service.InstancesOf("IISApplicationPool")
If bRecycleAll = 1 Then
'Recycle each apppool returned in the collection with a delay of
iRecycleDelay
For each APInstance in APCollection
WScript.Echo "Recycling " & strServer & "/" & APInstance.Name
APInstance.Recycle
WScript.Echo "Waiting " & iRecycleDelay & " seconds..."
Wscript.Sleep(iRecycleDelay*1000)
Next
Else
'If we're not recycling all apppools find the one that was specified and
recycle it
For each APInstance in APCollection
If UCase(ApInstance.Name) = UCase("W3SVC/AppPools/" &
strAppPoolName) Then
WScript.Echo "Recycling " & strServer & "/" & APInstance.Name
APInstance.Recycle
End If
Next
End If
WScript.Echo "Done!"