473,791 Members | 3,074 Online
Bytes | Software Development & Data Engineering Community
+ 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 15742
Hello M,

what's your "applicatio n 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 "applicatio n 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 IISApplicationP ool::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 "applicatio n 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
MCDirectorie s.
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 = "IIsApplication Pools"; // Case Sensitive
string ServerName = "LocalHost" ;
DirectoryEntry W3SVC = new DirectoryEntry( "IIS://" +
ServerName + "/w3svc", "", "");

foreach (DirectoryEntry Site in W3SVC.Children)
{
Console.WriteLi ne(Site.SchemaC lassName);
if (Site.SchemaCla ssName == WebServerSchema )
foreach (DirectoryEntry child in Site.Children)
{
Console.WriteLi ne(child.Parent + ": " +
child.Name);
if (child.Name == appPoolName)
{
PropertyCollect ion appPoolProps =
child.Propertie s;
foreach (string PropName in
appPoolProps.Pr opertyNames)
{
Console.WriteLi ne("Applicatio n
Pool: {0} - {1}", PropName, appPoolProps[PropName].Value);
}
appPoolProps["AppPoolCommand "].Value =
AppPoolCommandE num.stop; // 2==stop, 1==start
child.CommitCha nges();
}
}
Console.WriteLi ne(Site.Name + " - " +
Site.Properties["ServerComm ent"].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 IISApplicationP ool::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 "applicatio n 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 = "IIsApplication Pools"; // Case Sensitive
string ServerName = "LocalHost" ;
DirectoryEntry W3SVC = new DirectoryEntry( "IIS://" +
ServerName + "/w3svc", "", "");

foreach (DirectoryEntry Site in W3SVC.Children)
{
Console.WriteLi ne(Site.SchemaC lassName);
if (Site.SchemaCla ssName == WebServerSchema )
foreach (DirectoryEntry child in Site.Children)
{
Console.WriteLi ne(child.Parent + ": " +
child.Name);
if (child.Name == appPoolName)
{
PropertyCollect ion appPoolProps =
child.Propertie s;
foreach (string PropName in
appPoolProps.Pr opertyNames)
{
Console.WriteLi ne("Applicatio n
Pool: {0} - {1}", PropName, appPoolProps[PropName].Value);
}
appPoolProps["AppPoolCommand "].Value =
AppPoolCommandE num.stop; // 2==stop, 1==start
child.CommitCha nges();
}
}
Console.WriteLi ne(Site.Name + " - " +
Site.Properties["ServerComm ent"].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 IISApplicationP ool::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 "applicatio n 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******@newsg roups.nospamwro te in message
news:uK******** ******@TK2MSFTN GP05.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.Manageme nt and WMI is one option using scripting is another.

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

....

static void StopAppPool(str ing ConnectionUser, string ConnectionPassw ord,
string Machine, string appPool )
{
ConnectionOptio ns co = new ConnectionOptio ns();
co.Username = ConnectionUser;
co.Password = ConnectionPassw ord;
co.Impersonatio n = ImpersonationLe vel.Impersonate ;
co.Authenticati on = AuthenticationL evel.PacketPriv acy;
string objPath = "IISApplication Pool.Name='" + appPool + "'"; // watch the
single quotes!!

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

using(Managemen tObject mc = new ManagementObjec t(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
23084
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 to a pool. If I assign only one application to a applicaton pool and have multiple worker processes assigned to that pool. Will my application be processed by many worker processes?
13
2595
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 events. I see that when all sessions time out, Application stops. How can prevent application stop? -- ______________________________
5
3959
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 per appliction pool. Each worker process is dedicated to a pool. If I assign only one application to a applicaton pool then: 1) Can I have multiple worker processes assigned to that pool? If yes,what is the advantage of doing so?
1
2832
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. Despite entering the required lines to "my.ini" (the new my.cnf) through notepad AND MySQL Administrator, the cache does not work. So, today I took a peek at the 'Health' tab in MySQL Administrator.
2
5517
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 this working fine on one web server (http), but keep getting the error below on the other (https). I cannot see any difference in how I have set up the application pool, and the messages below do not shed any light on the matter. Can you help me...
0
1356
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 the website stops responding. Then, I need to open a "ticket" at the hosting company and wait till they restart the application.
5
4336
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 discovered this morning an inconsitency within the application pools of our website. Basically, we have a maze of cluttered folders and other gargabe within the website - with one main folder, called /secured/ running from the root of the website, which...
0
2589
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 and this solved the problem.
5
2641
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. In a nutshell, I understand how this can be considered desireable by some, but I am not one of those people. My situation is that we have a root site (hosted @ http://www.mydomain.com) in the root application folder '/'.
0
9517
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10428
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10156
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.