IIS AppCmd Reference

Microsoft IIS

IIS 7 includes AppCmd.exe, which is a new, one-stop executable for administering essentially every function IISprovides.Through AppCmd, you can create and configure sites, application pools, and virtual directories; start,stop, and recycle sites and pools; examine current activities in the core of the web server service; and generallyfind, copy, and import configurations of both IIS itself and the ASP.NET subcomponent.
AppCmd takes a logical syntax: you perform an operation, or command, on a specific piece of IIS, or an object.For example, you can list sites (list being the command and site being the object), add applications, deleteworker processes, or set configurations.

–> You can get a general sense of the scope of functions AppCmd supports by using the /? switch at a command line.

For example, we can list the sites that are stopped on a server by using the following command:

appcmd list sites /state:Stopped

We can add a completely new web site entirely from the command line. Let’s add a site named “Booksite” that
listens on port 81 and whose content is stored at c:\inetpub\wwwroot\booksite:
Code View:

appcmd add site /name:BookSite /id:2 /bindings:"http/*:81:" /physicalPath:"C:\inetpub\wwwroot\booksite"

I can change the identifier for my new site to number 99 using the following command:

appcmd set site "BookSite" /id:99

I can delete the site that I just added as follows:

appcmd delete site "Booksite"

To create a backup, which will allow you to fix unwanted changes to server configuration and return to a
configuration that, at one point, functioned correctly, it’s a simple one-line command:

appcmd add backup 20071015

You can then display a list of available backups using the first command below, and then restore one of them using the second command (the restore command stops the server, adds the configuration from the backup,and then restarts the server):

appcmd list backups
appcmd restore backup "20071015"

If you start piping output of one command and feeding to another command, you can achieve some useful outcomes. For example, to recycle all application pools, you can use:

appcmd list apppool /xml | appcmd recycle apppool /in

You can also recycle application pools serving a specific web site; in this example, let’s say “Company Web”:
Code View:

appcmd list site "Company Web" /xml | appcmd list app /in /xml | appcmd list
apppool/in /xml | appcmd recycle apppool /in
appcmd list app /site.name:"Company Web" /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in

We can start all of the sites we stopped in the earlier example in this section with the following command:
appcmd list site /state:stopped /xml | appcmd start site /in
You can do directory or file maintenance on a certain directory safely by determining which sites read from a
specific location, like C:\inetpub\wwwroot:
Code View:

appcmd list vdir /physicalPath:C\inetpub\wwwroot /xml | appcmd list app /xml /in |
appcmd list site /in

You can also see what applications are served by worker process 2450:
Code View:

appcmd list wp 2450 /xml | appcmd list apppool /xml /in | appcmd list app /in

And perhaps useful for a quick scan of serving problems, you can retrieve a list of all sites generating 404 errors, indicating that a page cannot be found by IIS:

appcmd list trace /statusCode:404 /xml | appcmd list site /in

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.