On Mon, Nov 22, 2010 at 4:55 AM, IAK <giviglie / gmail.com> wrote:

> Hi, I'm not expert in Ruby....In my company we use a Ruby script to
> deploy some services. No we need to implement the script stopping the
> IIS application pool during deployment and then restart it....
> Is there any way to do that in Ruby??? Someone here tells me that ruby
> prepares coffe and cappuccino too....but...for IIS...I don't know how
> to do it....
> Any help will be very appreciated.
> Thanks in advance
>
> Giacomo
>
>
Google led me to this page:
http://learn.iis.net/page.aspx/163/managing-applications-and-application-pools-on-iis-70-with-wmi/
 .

I modified the code snippets to ruby.

# ===  Stopping an Application Pool ===

require 'win32ole'

# Connect to the WMI WebAdministration namespace.
web_admin = WIN32OLE.connect("winmgmts:root\\WebAdministration")

# Specify the application pool.
app_pool = web_admin.get("ApplicationPool.Name='DefaultAppPool'")

# Stop the application pool.
app_pool.stop


# === Starting an Application Pool ===

require 'win32ole'

# Connect to the WMI WebAdministration namespace.
web_admin = WIN32OLE.connect("winmgmts:root\\WebAdministration")

# Specify the application pool.
app_pool = web_admin.get("ApplicationPool.Name='DefaultAppPool'")

# Start the application pool.
app_pool.start


# === Recycling an Application Pool ===

require 'win32ole'

web_admin = WIN32OLE.connect("winmgmts:root\\WebAdministration")
app_pool = web_admin.get("ApplicationPool.Name='DefaultAppPool'")

# Recycle the application pool.
app_pool.recycle