473,473 Members | 2,138 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 15724
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: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.