Programmatically Recycling IIS Application Pools

  • Thread starter Thread starter Ram
  • Start date Start date
R

Ram

Hey,
Is there a way to remotely Recycle IIS 6.0 Application Pools in .Net?
Thanks ahead

--Ram
 
to recycle using script see this
http://groups.google.ca/[email protected]&rnum=1
for codebehind see this

void RestartApplicationPool(string applicationPoolName)
{
if (applicationPoolName == null)
{
throw new ArgumentNullException("applicationPoolName");
}

using (DirectoryEntry applicationPool = new
DirectoryEntry("IIS://localhost/W3SVC/AppPools/" + applicationPoolName))
{
applicationPool.Invoke("Recycle");
}
}

--
Regards,
Alvin Bruney

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
 
Thanks alot!

Ram
Alvin Bruney said:
to recycle using script see this
http://groups.google.ca/groups?q=recycle+app+pool&hl=en&lr=&selm=OptknwINDHA
..3664%40tk2msftngp13.phx.gbl&rnum=1
for codebehind see this

void RestartApplicationPool(string applicationPoolName)
{
if (applicationPoolName == null)
{
throw new ArgumentNullException("applicationPoolName");
}

using (DirectoryEntry applicationPool = new
DirectoryEntry("IIS://localhost/W3SVC/AppPools/" + applicationPoolName))
{
applicationPool.Invoke("Recycle");
}
}

--
Regards,
Alvin Bruney

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
------------------------------------------------------------

Ram said:
Hey,
Is there a way to remotely Recycle IIS 6.0 Application Pools in .Net?
Thanks ahead

--Ram
 
Um...
Well I just tested the same code (the code you gave me earlier) on VS.NET
2003 and it didnt work!
When trying to bind the DirecforyEntry, I get:
"The Value Provided For adsObject Does Not Implement IADs"
While the SAME code works perfectly well on VS.NET 2005 - (Whiebey's
Beta)!!!
Please Help!

Ram
Alvin Bruney said:
to recycle using script see this
http://groups.google.ca/groups?q=recycle+app+pool&hl=en&lr=&selm=OptknwINDHA
..3664%40tk2msftngp13.phx.gbl&rnum=1
for codebehind see this

void RestartApplicationPool(string applicationPoolName)
{
if (applicationPoolName == null)
{
throw new ArgumentNullException("applicationPoolName");
}

using (DirectoryEntry applicationPool = new
DirectoryEntry("IIS://localhost/W3SVC/AppPools/" + applicationPoolName))
{
applicationPool.Invoke("Recycle");
}
}

--
Regards,
Alvin Bruney

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
------------------------------------------------------------

Ram said:
Hey,
Is there a way to remotely Recycle IIS 6.0 Application Pools in .Net?
Thanks ahead

--Ram
 
Back
Top