ASPNetFAQ.com: What is ASP.NET?

Technology posts on ASP.NET, IIS, Windows (+ a little Linux), Cloud Servers, Hosting, and more!
  • Blog Home
Search the site...

Starting All Sites in IIS on a Windows Server

Tweet
Share
0 Shares

So I recently had to do some work on a server that required stopping all sites in IIS but without stopping IIS itself. Here’s the short post on how I did that. Now of course I needed to have all the sites turned back on again. Just restarting IIS wouldn’t do what I needed – it seems to remember what sites were running before the reset. So, here’s a quick little script, which is just the inverse of the previous script, to start all sites.

c:\windows\system32\inetsrv\appcmd.exe list site /xml /state:"$=stopped" | appcmd start site /in

There you go. Simple as could be. This loops through and lists all the sites currently with their running state set to “stopped”, pipes it into the next command, which just starts each of the sites in the list.




By the way this is super fast. Even on a server with hundreds of sites it only took a second or two to run.

Happy IIS hosting! :)

More from my site

  • Setting up SSL in IIS7Setting up SSL in IIS7
  • Video: Introducing Bootstrap for ASP.NET Web Development Across Multiple DevicesVideo: Introducing Bootstrap for ASP.NET Web Development Across Multiple Devices
  • Video: Agile .NET DevelopmentVideo: Agile .NET Development
  • Enable Caching in IIS to Speed PerformanceEnable Caching in IIS to Speed Performance
  • Change the WordPress Domain Name After Moving a SiteChange the WordPress Domain Name After Moving a Site
Tweet
Share
0 Shares

6 comments on “Starting All Sites in IIS on a Windows Server”

  1. FJS says:
    December 14, 2014 at 10:13 am

    Why not just use iisreset /STOP to stop IIS? and iisreset /START it’s built in to IIS and accessed from the cli.

    or just iisreset /NOFORCE to restart iis gracefully. See below for CLI usage:

    I do like your script though and think it’s useful if you wanted to stop just websites and not all IIS services.

    IISRESET.EXE (c) Microsoft Corp. 1998-1999

    Usage:
    iisreset [computername]

    /RESTART Stop and then restart all Internet services.
    /START Start all Internet services.
    /STOP Stop all Internet services.
    /REBOOT Reboot the computer.
    /REBOOTONERROR Reboot the computer if an error occurs when starting,
    stopping, or restarting Internet services.
    /NOFORCE Do not forcefully terminate Internet services if
    attempting to stop them gracefully fails.
    /TIMEOUT:val Specify the timeout value ( in seconds ) to wait for
    a successful stop of Internet services. On expiration
    of this timeout the computer can be rebooted if
    the /REBOOTONERROR parameter is specified.
    The default value is 20s for restart, 60s for stop,
    and 0s for reboot.
    /STATUS Display the status of all Internet services.
    /ENABLE Enable restarting of Internet Services
    on the local system.
    /DISABLE Disable restarting of Internet Services
    on the local system.

    • Brad Kingsley says:
      December 15, 2014 at 1:46 pm

      I only wanted to stop the sites, not all IIS services.

  2. FJS says:
    December 14, 2014 at 10:15 am

    To stop web sites, they’re are also vbs script examples admsrv you can stop any site individually using the metabase root name. I see now you just wanted to stop the sites, not FTP or SMTP I am guessing. In fact, there is a com object you can stop right from a script using it.

    • Brad Kingsley says:
      December 15, 2014 at 1:47 pm

      Correct – needed to stop the sites without impacting the other IIS services. COM? Ick. People still use COM? :)

  3. Robert Burke says:
    December 24, 2014 at 4:21 pm

    Thank you Brad, God bless you and Merry Christmas

  4. mosesyous says:
    January 21, 2015 at 4:29 am

    More help about control “IIS services”

Proverbs 19:20

"Get all the advice and instruction you can, so you will be wise the rest of your life."

A Note On WordPress Hosting

Our main focus is of course .NET, but with a mix of Linux, virtualization, and other technologies. But if you're really looking for the best WordPress hosting specifically, read my WordPress host review to save yourself hassle AND money!




Recent Posts

  • What makes good web hosting?
  • jQuery Mobile C# ASP.NET and N5 Networks Software Repository
  • Open Source Bug Tracking Software and the Orchard Project
  • ASP.NET Development with Dreamweaver MX: Visual QuickPro Guide
  • Kendo UI Sample, ASP.NET Ajax Tutorial & More

Tags

ASP.NET Automation centos CMS css cytanium Development/Coding Email gmail Hosting htaccess http https IIS javascript Learning Linux logparser MySQL nginx openssl OrcsWeb performance PowerShell redirect RHEL security server SherWeb smtp SQL/Databases ssl System Administration telnet terminal tip Troubleshooting Ubuntu virtualization Visual Studio web farm web hosting Windows windows server Wordpress

Categories

  • ASP.net development
  • Development/Coding
  • Hosting
  • IIS (Internet Information Services)
  • SQL/Databases
  • System Administration
  • Virtualization
(c) ASPNETFAQ.com