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.argumen ts.count = 0 Then
WScript.Echo "Syntax: recycleap server [AppPoolName]"
WScript.Echo
WScript.Echo "Example: recycleap servername DefaultAppPool"
WScript.Quit (0)
Else
strServer = WScript.argumen ts(0)
If WScript.argumen ts.count > 1 Then
strAppPoolName = WScript.argumen ts(1)
bRecycleAll = 0
End If
End If
'Connect to the specified server using WMI
set Locator = CreateObject("W bemScripting.SW bemLocator")
Locator.Securit y_.Authenticati onLevel = 6
set Service = locator.connect server(strServe r,"root/MicrosoftIISv2" )
'Get a collection of WMI apppools
set APCollection = Service.Instanc esOf("IISApplic ationPool")
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.Recy cle
WScript.Echo "Waiting " & iRecycleDelay & " seconds..."
Wscript.Sleep(i RecycleDelay*10 00)
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(ApInstanc e.Name) = UCase("W3SVC/AppPools/" &
strAppPoolName) Then
WScript.Echo "Recycling " & strServer & "/" & APInstance.Name
APInstance.Recy cle
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.argumen ts.count = 0 Then
WScript.Echo "Syntax: recycleap server [AppPoolName]"
WScript.Echo
WScript.Echo "Example: recycleap servername DefaultAppPool"
WScript.Quit (0)
Else
strServer = WScript.argumen ts(0)
If WScript.argumen ts.count > 1 Then
strAppPoolName = WScript.argumen ts(1)
bRecycleAll = 0
End If
End If
'Connect to the specified server using WMI
set Locator = CreateObject("W bemScripting.SW bemLocator")
Locator.Securit y_.Authenticati onLevel = 6
set Service = locator.connect server(strServe r,"root/MicrosoftIISv2" )
'Get a collection of WMI apppools
set APCollection = Service.Instanc esOf("IISApplic ationPool")
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.Recy cle
WScript.Echo "Waiting " & iRecycleDelay & " seconds..."
Wscript.Sleep(i RecycleDelay*10 00)
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(ApInstanc e.Name) = UCase("W3SVC/AppPools/" &
strAppPoolName) Then
WScript.Echo "Recycling " & strServer & "/" & APInstance.Name
APInstance.Recy cle
End If
Next
End If
WScript.Echo "Done!"
Comment