473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to stop an Application Pool in IIS 6.0 in c#?

I'm trying to write a custom installation engine to plug into our
existing build system. Some things I'm trying to do are,
Create/Delete/Start/Stop Application Pools, Web Sites, and Virtual
Directories.

At this point I'd be happy if someone can provide a sample of how to
Stop an application pool. Or point me in the right direction.

Thanks!

Mike
Sep 7 '06 #1
6 15715
Hello M,

what's your "application pools" ?
How do u create them?

Not so clear for me

MCI'm trying to write a custom installation engine to plug into our
MCexisting build system. Some things I'm trying to do are,
MCCreate/Delete/Start/Stop Application Pools, Web Sites, and Virtual
MCDirectories.
MC>
MCAt this point I'd be happy if someone can provide a sample of how to
MCStop an application pool. Or point me in the right direction.
MC>
MCThanks!
MC>
MCMike
MC>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 7 '06 #2
In IIS 6.0 I manually create seperate application pools for each web
site I host on our servers. This way each web site runs in it's own
memory space and can be recycled independant of the other web sites.

Steps to Create:
1. Open compmgmt.msc
2. Expand Services and Applications
3. Expand Internet Information Services
4. Expand Application Pools (Windows 2003 Server)
5. New -Application Pool...
6. Give it a name, click OK.
7. Open properties to a web site
8. Click Home Directory
9. Change Application pool to your new pool name. click Ok.


Michael Nemtsev wrote:
Hello M,

what's your "application pools" ?
How do u create them?

Not so clear for me

MCI'm trying to write a custom installation engine to plug into our
MCexisting build system. Some things I'm trying to do are,
MCCreate/Delete/Start/Stop Application Pools, Web Sites, and Virtual
MCDirectories.
MCMCAt this point I'd be happy if someone can provide a sample of
how to
MCStop an application pool. Or point me in the right direction.
MCMCThanks!
MCMCMike
MC---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Sep 7 '06 #3
Hello M,

AFAIK, pools are created by IIS for each new virtual folder, u need only
to point that this folder works with that pool
ADSI helps u to manage IIS pools, but ADSI is unmanaged http://msdn.microsoft.com/library/de...5344a7b851.asp

To stop pool use IISApplicationPool::Stop http://msdn.microsoft.com/library/de...b2de05644c.asp

in this case u need to make your calls via interop

MCIn IIS 6.0 I manually create seperate application pools for each web
MCsite I host on our servers. This way each web site runs in it's own
MCmemory space and can be recycled independant of the other web sites.
MC>
MCSteps to Create:
MC1. Open compmgmt.msc
MC2. Expand Services and Applications
MC3. Expand Internet Information Services
MC4. Expand Application Pools (Windows 2003 Server)
MC5. New -Application Pool...
MC6. Give it a name, click OK.
MC7. Open properties to a web site
MC8. Click Home Directory
MC9. Change Application pool to your new pool name. click Ok.
MCMichael Nemtsev wrote:
MC>
>Hello M,

what's your "application pools" ?
How do u create them?
Not so clear for me

MCI'm trying to write a custom installation engine to plug into our
MCexisting build system. Some things I'm trying to do are,
MCCreate/Delete/Start/Stop Application Pools, Web Sites, and
Virtual
MCDirectories.
MCMCAt this point I'd be happy if someone can provide a sample of
how to
MCStop an application pool. Or point me in the right direction.
MCMCThanks!
MCMCMike
MC---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 7 '06 #4
Thanks but C++ isn't my thing! :)

I did find a solution:
const string WebServerSchema = "IIsApplicationPools"; // Case Sensitive
string ServerName = "LocalHost";
DirectoryEntry W3SVC = new DirectoryEntry("IIS://" +
ServerName + "/w3svc", "", "");

foreach (DirectoryEntry Site in W3SVC.Children)
{
Console.WriteLine(Site.SchemaClassName);
if (Site.SchemaClassName == WebServerSchema)
foreach (DirectoryEntry child in Site.Children)
{
Console.WriteLine(child.Parent + ": " +
child.Name);
if (child.Name == appPoolName)
{
PropertyCollection appPoolProps =
child.Properties;
foreach (string PropName in
appPoolProps.PropertyNames)
{
Console.WriteLine("Application
Pool: {0} - {1}", PropName, appPoolProps[PropName].Value);
}
appPoolProps["AppPoolCommand"].Value =
AppPoolCommandEnum.stop; // 2==stop, 1==start
child.CommitChanges();
}
}
Console.WriteLine(Site.Name + " - " +
Site.Properties["ServerComment"].Value.ToString());
}

This is working for me.

Thanks.

Michael Nemtsev wrote:
Hello M,

AFAIK, pools are created by IIS for each new virtual folder, u need only
to point that this folder works with that pool
ADSI helps u to manage IIS pools, but ADSI is unmanaged
http://msdn.microsoft.com/library/de...5344a7b851.asp
To stop pool use IISApplicationPool::Stop
http://msdn.microsoft.com/library/de...b2de05644c.asp
in this case u need to make your calls via interop

MCIn IIS 6.0 I manually create seperate application pools for each web
MCsite I host on our servers. This way each web site runs in it's own
MCmemory space and can be recycled independant of the other web sites.
MCMCSteps to Create:
MC1. Open compmgmt.msc
MC2. Expand Services and Applications
MC3. Expand Internet Information Services
MC4. Expand Application Pools (Windows 2003 Server)
MC5. New -Application Pool...
MC6. Give it a name, click OK.
MC7. Open properties to a web site
MC8. Click Home Directory
MC9. Change Application pool to your new pool name. click Ok.
MCMichael Nemtsev wrote:
MC>
>>Hello M,

what's your "application pools" ?
How do u create them?
Not so clear for me

MCI'm trying to write a custom installation engine to plug into our
MCexisting build system. Some things I'm trying to do are,
MCCreate/Delete/Start/Stop Application Pools, Web Sites, and
Virtual
MCDirectories.
MCMCAt this point I'd be happy if someone can provide a sample of
how to
MCStop an application pool. Or point me in the right direction.
MCMCThanks!
MCMCMike
MC---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Sep 7 '06 #5
Thanks but C++ isn't my thing! :)

I did find a solution:
const string WebServerSchema = "IIsApplicationPools"; // Case Sensitive
string ServerName = "LocalHost";
DirectoryEntry W3SVC = new DirectoryEntry("IIS://" +
ServerName + "/w3svc", "", "");

foreach (DirectoryEntry Site in W3SVC.Children)
{
Console.WriteLine(Site.SchemaClassName);
if (Site.SchemaClassName == WebServerSchema)
foreach (DirectoryEntry child in Site.Children)
{
Console.WriteLine(child.Parent + ": " +
child.Name);
if (child.Name == appPoolName)
{
PropertyCollection appPoolProps =
child.Properties;
foreach (string PropName in
appPoolProps.PropertyNames)
{
Console.WriteLine("Application
Pool: {0} - {1}", PropName, appPoolProps[PropName].Value);
}
appPoolProps["AppPoolCommand"].Value =
AppPoolCommandEnum.stop; // 2==stop, 1==start
child.CommitChanges();
}
}
Console.WriteLine(Site.Name + " - " +
Site.Properties["ServerComment"].Value.ToString());
}

This is working for me.

Thanks.

Michael Nemtsev wrote:
Hello M,

AFAIK, pools are created by IIS for each new virtual folder, u need only
to point that this folder works with that pool
ADSI helps u to manage IIS pools, but ADSI is unmanaged
http://msdn.microsoft.com/library/de...5344a7b851.asp
To stop pool use IISApplicationPool::Stop
http://msdn.microsoft.com/library/de...b2de05644c.asp
in this case u need to make your calls via interop

MCIn IIS 6.0 I manually create seperate application pools for each web
MCsite I host on our servers. This way each web site runs in it's own
MCmemory space and can be recycled independant of the other web sites.
MCMCSteps to Create:
MC1. Open compmgmt.msc
MC2. Expand Services and Applications
MC3. Expand Internet Information Services
MC4. Expand Application Pools (Windows 2003 Server)
MC5. New -Application Pool...
MC6. Give it a name, click OK.
MC7. Open properties to a web site
MC8. Click Home Directory
MC9. Change Application pool to your new pool name. click Ok.
MCMichael Nemtsev wrote:
MC>
>>Hello M,

what's your "application pools" ?
How do u create them?
Not so clear for me

MCI'm trying to write a custom installation engine to plug into our
MCexisting build system. Some things I'm trying to do are,
MCCreate/Delete/Start/Stop Application Pools, Web Sites, and
Virtual
MCDirectories.
MCMCAt this point I'd be happy if someone can provide a sample of
how to
MCStop an application pool. Or point me in the right direction.
MCMCThanks!
MCMCMike
MC---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Sep 7 '06 #6

"M Craig" <mc******@newsgroups.nospamwrote in message
news:uK**************@TK2MSFTNGP05.phx.gbl...
| I'm trying to write a custom installation engine to plug into our
| existing build system. Some things I'm trying to do are,
| Create/Delete/Start/Stop Application Pools, Web Sites, and Virtual
| Directories.
|
| At this point I'd be happy if someone can provide a sample of how to
| Stop an application pool. Or point me in the right direction.
|
| Thanks!
|
| Mike
Using System.Management and WMI is one option using scripting is another.

StopAppPool("admin", "adminPwd", "remServer", "W3SVC/AppPools/MyAppPool");

....

static void StopAppPool(string ConnectionUser, string ConnectionPassword,
string Machine, string appPool )
{
ConnectionOptions co = new ConnectionOptions();
co.Username = ConnectionUser;
co.Password = ConnectionPassword;
co.Impersonation = ImpersonationLevel.Impersonate;
co.Authentication = AuthenticationLevel.PacketPrivacy;
string objPath = "IISApplicationPool.Name='" + appPool + "'"; // watch the
single quotes!!

ManagementScope scope = new ManagementScope(@"\\" + Machine +
@"\root\MicrosoftIISV2", co);

using(ManagementObject mc = new ManagementObject(objPath))
{
mc.Scope = scope;
mc.InvokeMethod("Stop", null, null);
}
}

Please consult:
http://msdn.microsoft.com/library/de...43ffc70e16.asp

for more details.
Sep 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
13
by: Ĺženol Akbulak | last post by:
Hi, I have an asp.net application. And I have worker threads which must run always (7x24). I start my threads in Application_Start, and I stop its in Application_Stop events. I log this...
5
by: J-T | last post by:
I guess I'm a litte bit confused about app pool and worker process. In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process...
1
by: Good Man | last post by:
Hi there I've noticed some very weird things happening with my current MySQL setup on my XP Laptop, a development machine. For a while, I have been trying to get the MySQL cache to work....
2
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have 2 web servers on which I am running a .net version 2 application, both of which I want to use an application pool with the same domain user's id and password to tighten security. I have...
0
by: Si | last post by:
Hi, I'm working on a small project - a website with some access to DBs, etc. On my dev PC, all works fine. But on the hosting machine, after a short while, I get "Service Unavailable" and...
5
markrawlingson
by: markrawlingson | last post by:
Hey guys, Having a bit of a complicated issue here so please bare with me while I explain. I'm also not a system admin and don't know a whole lot about IIS, so i apologize in advance. I...
0
by: sillz | last post by:
On Apr 8, 2:00 pm, sillz <beth.sto...@gmail.comwrote: I never could get this to work. The oracle account tested fine. I ended up creating a new account in Windows with the right permissions...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.