IIS7 Appcmd Command Explanation
Don't talk nonsense! Although there is a configuration Interface manager! But command creation is essential when installing packages! Recently used NSIs to make the installation package carefully studied the Appcmd command, it is fully functional.
On the Internet to check some information, those blogs are mostly reproduced by others. is a basic introduction, many of the commands are not introduced (I do not know if it is not my mistaken).
Even Microsoft's technical resource pool is not detailed:
Address: http://technet.microsoft.com/zh-cn/library/cc772200 (ws.10). aspx (anyway I looked it over!) Didn't find what I asked for)
Microsoft's Technical Resource Library I do not introduce, click on the link above to see it.
(introduce some of the commands we can use, currently only contains site operations, the other AppPool config app VDir later time to join)
One: the preparatory work
APPcmd.exe in the C:\Windows\System32\inetsrv directory
Switch to this directory using Cd c:\Windows\System32\inetsrv
II: Introduction to command operations
IIS Command-Line administration Tool basic format:
APPCMD (command) (object type) < identifier > </parameter 1: value 1 ...>
Supported Object types:
Management of Site virtual sites
App Management app
VDIR Managing virtual Directories
AppPool Managing Application Pools
Config Management General configuration section
WP Management work Process
Request to manage HTTP requests
Module Management Server Modules
Backup Management Server Configuration Backups
Trace logs using failed request tracing
-----------This does not explain very detailed, understand the people know this level of IIS.
Three: A detailed command of the Site
1. Command Introduction
Management of virtual sites
APPCMD < command > SITE [identifier] [-Parameter 1: value 1 ...] Example: Appcmd list site (lists the sites that currently exist)
Supported commands:
List List Virtual sites
Set Configuration virtual site
Add New virtual site
Delete Deletes a virtual site
Start Startup virtual site
Stop stopping a virtual site
2. Detailed
List Virtual Sites
APPCMD list SITE [identifier] [-Parameter 1: value 1 ...]
Lists the virtual sites on the computer. This command can be used to find the site using the identifier or URL of a specific site, or
Matches 0 or more sites based on a specified site property.
Example:
Appcmd List Sites
Lists all sites on the computer.
Appcmd list Site "Default Web site"
Find the Site "Default Web site".
Appcmd List Site Http://localhost/app1
Finds the site associated with the specified URL.
Appcmd List Site/serverautostart:false
Look for all sites that have the "ServerAutoStart" configuration Property set to "false".
Add a new virtual site
APPCMD add SITE [identifier] [-Parameter 1: value 1 ...]
Creates a new virtual site with the specified settings. At a minimum, the site name and ID must be provided.
Supported parameters:
/name (required) Site name
/ID Site ID
/bindings "Http://domain:port,..." friendly format or "protocol/bindinginformation,..." binding list in original format
/physicalpath
If specified, causes the root application to be created for the site that contains the root virtual directory that points to the specified path. If you suddenly
, a site without a root application will be created, and the site will not start until the root application is created.
Example:
Appcmd add Site/name: "My New site"/id:2/bindings:http://www.domain.com:80
Creates a new site "My new site" with the specified good-memory bindings to listen on port 80 on the WWW.D
HTTP request for omain.com.
Appcmd add Site/name: "My New site"/id:2/bindings:http://*:81
Creates a new site "My new site" with the specified good-memory bindings to listen on port 81 on any domain
HTTP request for the name.
Appcmd add Site/name: "My New Site"/id:2/bindings:http/*:81:
Creates a new site, my new site, with the specified ID and bindings. After creation, no apps are included in the new site
Program.
Appcmd add Site/name: "My New Site"/id:2/bindings:http/*:81:/physicalpath: "C
: \inetpub\mynewsite "
Creates a new site, my new site, with the specified ID and bindings. The system will automatically create a root virtual directory pointing to the
The root application for the physical path.
Appcmd add Site/name: "My New site"/bindings:http/*:81:
Create a new site "My new site" with bindings and automatically generate the site ID. After it is created, the new site does not contain
Any application.
Configure a virtual site
APPCMD set SITE [identifier] [-Parameter 1: value 1 ...]
Allows you to set properties for the specified virtual site. You must provide an accurate site identifier, and you must resolve the identifier to an existing
There are sites.
Supported parameters:
Identifier (required)
Site name or URL of the site to be modified
/site.name
Site name or URL of the site to be modified (same as identifier)
/bindings
"Http://domain:port,..." friendly format or "Protocol/bindinginformation,..." original
Binding List of formats
Example:
Appcmd set Site "Default Web site"/serverautostart:false/id:100
Set the "ServerAutoStart" and "id" properties for the "Default Web site" site.
There are some advanced actions attached to the set operation (important)
At that time with Appcmd set site "Default Web site" At that time other advanced parameters
Explain the follow-up .....
-name Name
-id ID Identification
Whether the-serverautostart starts automatically
-bindings. [protocol= ' string ', bindinginformation= ' string '].P
-bindings. [protocol= ' string ', bindinginformation= ' string '].b
-limits.maxbandwidth
-limits.maxconnections
-limits.connectiontimeout
-logfile.logextfileflags
-logfile.customlogpluginclsid
-logfile.logformat
-logfile.directory
-logfile.period
-logfile.truncatesize
-logfile.localtimerollover
-logfile.enabled
-tracefailedrequestslogging.enabled
-tracefailedrequestslogging.directory
-tracefailedrequestslogging.maxlogfiles
-tracefailedrequestslogging.maxlogfilesizekb
-tracefailedrequestslogging.customactionsenabled
-applicationdefaults.path
-applicationdefaults.applicationpool
-applicationdefaults.enabledprotocols
-virtualdirectorydefaults.path
Physical path to the-virtualdirectorydefaults.physicalpath Web site
-virtualdirectorydefaults.username account for physical path credentials
-virtualdirectorydefaults.password the password for the physical path credential
-virtualdirectorydefaults.logonmethod
-virtualdirectorydefaults.allowsubdirconfig
-[path= ' String '].path
-[path= ' String '].applicationpool
-[path= ' String '].enabledprotocols
-[path= ' String '].virtualdirectorydefaults.path
-[path= ' String '].virtualdirectorydefaults.physicalpath
-[path= ' String '].virtualdirectorydefaults.username
-[path= ' String '].virtualdirectorydefaults.password
-[path= ' String '].virtualdirectorydefaults.logonmethod
-[path= ' String '].virtualdirectorydefaults.allowsubdirconfig
-[path= ' string ']. [path= ' String '].path
-[path= ' string ']. [path= ' String '].physicalpath
-[path= ' string ']. [path= ' String '].username
-[path= ' string ']. [path= ' String '].password
-[path= ' string ']. [path= ' String '].logonmethod
-[path= ' string ']. [path= ' String '].allowsubdirconfig
Delete a virtual site
APPCMD delete SITE [identifier] [-Parameter 1: value 1 ...]
Describe: Deletes the specified virtual site from the computer. You must provide an accurate site identifier, and the identifier must be resolved to an existing site.
Supported parameters:
Identifier (required) the site name or URL of the site to be deleted
/site.name the site name or URL of the site to be deleted (same as identifier)
Example:
Appcmd Delete Site "Default Web Site" deletes the Web "Default Web Site".
Start a virtual site
APPCMD start SITE [identifier] [-Parameter 1: value 1 ...]
Starts the specified virtual site and enables the site to start listening for new requests on all its binding endpoints. You must provide an accurate site identifier, and the identifier must be resolved to an existing site.
Supported parameters:
Identifier (required) the site name or URL of the site to start
/site.name the site name or URL of the site to start (same as identifier)
Example:
Appcmd start Site "Default Web site"
Start the site "Default Web site".
Stop a virtual site
APPCMD stop SITE [identifier] [-Parameter 1: value 1 ...]
Stops the specified virtual site and prevents new requests from being received on its bound endpoint. You must provide an accurate site identifier, and
The identifier must be resolved to an existing site.
Supported parameters:
Identifier (required) the site name or URL of the site to stop
/site.name site name or URL of the site to stop (same as identifier)
Example:
Appcmd stop Site "Default Web site"
Stop the site "Default Web site".
1 adding applications to the pool
Appcmd.exe add apppool/name:test.com/managedruntimeversion: "v4.0"/managedpipelinemode: "Integrated"
2 add site, specify site name, bind, physical path
Appcmd.exe add Site/name: "test.com"/id:1/bindings:http/*:81 :/physicalpath: "E:\webroot\test.com\Web"
3 designated sites for the city pool
Appcmd.exe set Site/site.name: "test.com"/[path= '/'].applicationpool:test.com
4 The default document for the specified site is index.aspx
Appcmd.exe set config "test.com/"/section:defaultdocument/+files. [@start, value= ' index.aspx ']/commit: "test.com"
5 closing script execution permissions for a specific directory
Appcmd set config "Test.com/download"/section:handlers/accesspolicy:read
6 exporting all application process pools on a machine
%windir%/system32/inetsrv/appcmd list Apppool/config/xml > C:/apppools.xml
7 Exporting all sites on 1 machines
%windir%/system32/inetsrv/appcmd list Site/config/xml > C:/sites.xml
8 Import all Process pools
%windir%/system32/inetsrv/appcmd Add Apppool/in < C:/apppools.xml
9 Import All Sites
%windir%/system32/inetsrv/appcmd Add Site/in < C:/sites.xml
The following is a batch script
10 Authorization to site files
ICACLS e:\webroot\test.com\/inheritance:e/grant:r "IIS apppool\test.com": R
ICACLS e:\webroot\test.com\*/inheritance:e/grant:r "IIS apppool\test.com": R
ICACLS e:\webroot\test.com\download/grant:m "IIS apppool\test.com": R
ICACLS e:\webroot\test.com\download\*/grant:m "IIS apppool\test.com": R
*******************************************************SetSitename=test.comSetSitepath=E:\webroot\test.comSetLogpath=G:\logfileSetDefaultdocument='index.aspx'SetIs32bitapp =FalseSetbackport= AboutSetNetversion=v4.0SetCache=Cache%windir%\system32\inetsrv\appcmd Add apppool/name:%sitename%/managedruntimeversion:%netversion%/ Managedpipelinemode:"Integrated"/Enable32bitapponwin64:false%windir%\system32\inetsrv\appcmd Add Site/name:"%sitename%"/ID: -/bindings:http/*:%backport%:,http/*:80:%sitename%/physicalpath:%sitepath%/logfile.directory:%logpath%%windir%\system32\inetsrv \appcmd set Site/site.name: "%sitename%"/[path= '/'].applicationpool:%sitename%%windir%\system32\inetsrv\appcmd set Config "%sitename%/"/section:defaultdocument/+files. [@start, value=%defaultdocument%]/commit: "%sitename%" ICACLS%sitepath%/inheritance:e/grant:r "IIS apppool\% Sitename% ": Ricacls%sitepath%\*/inheritance:e/grant:r" IIS apppool\%sitename% ": Ricacls%SitePath%\%Cache%/ Inheritance:e/grant:r "IIS apppool\%sitename%": Ricacls%sitepath%\%cache%/inheritance:e/grant:R "IIS AppPool\% Sitename% ": R waters 2017-04-04 14:44:51set sitename=test.comset sitepath=e:\webroot\test.comset LogPath=G:\logfileset Defaultdocument= ' index.aspx ' set Is32bitapp =falseset backport=99set netversion=v4.0set Cache=Cache%windir%\system32 \inetsrv\appcmd Add apppool/name:%sitename%/managedruntimeversion:%netversion%/managedpipelinemode: "Integrated"/ Enable32bitapponwin64:false%windir%\systEm32\inetsrv\appcmd add Site/name: "%sitename%"/id:100/bindings:http/*:%backport%:,http/*:80:%sitename%/ physicalpath:%sitepath%/logfile.directory:%logpath%%windir%\system32\inetsrv\appcmd set Site/site.name: "% Sitename% "/[path="/'].applicationpool:%sitename%%windir%\system32\inetsrv\appcmd set config "%Sitename%/"/section :d efaultdocument/+files. [@start, value=%defaultdocument%]/commit: "%sitename%" ICACLS%sitepath%/inheritance:e/grant:r "IIS apppool\% Sitename% ": Ricacls%sitepath%\*/inheritance:e/grant:r" IIS apppool\%sitename% ": Ricacls%SitePath%\%Cache%/ Inheritance:e/grant:r "IIS apppool\%sitename%": Ricacls%sitepath%\%cache%/inheritance:e/grant:R "IIS AppPool\% Sitename% ": R
Iis7appcmd command Explanation