IIS 7 provides a new command-line tool, Appcmd.exe, that you can use to configure and query objects on a WEB server and return output in text or XML format. Here are some examples of tasks that you can accomplish with Appcmd.exe:
• Create and configure sites, applications, application pools, and virtual directories.
• Stop and start the site.
• Start, stop, and recycle application pools.
• View information about the worker processes and requests that are running on the WEB server.
Appcmd.exe provides consistent commands for common query and configuration tasks, reducing the complexity of learning grammars. For example, you can use the List command to search for information about an object, such as an application, or you can use the Add command to create an object, such as a site.
In addition, you can combine commands to return more complex data related to objects on a WEB server, or to perform more complex tasks. For example, you can accomplish a complex task similar to the following: Stop all sites that have a request running longer than 60 seconds.
The AppCmd.exe tool is located in the directory *c:\windows\sytstem32\inetsrv* directory
When you use the command line to manage IIS 7.0, you need to use the new administrative tools provided by IIS7.0 AppCmd.exe. The AppCmd.exe tool can complete the Web server's entire management work. Using the AppCmd.exe tool, you can finish the work of the calendar through the command prompt, or you can complete the management through the script. Using the AppCmd.exe tool, you can do the following:
1. Add, delete, modify Web sites and application pools
2, stop, start Web site and application pool
3. Observe work process and request information
4, a list of IIS and ASP.net configuration information, and support for the IIS and ASP.net configuration information to modify
The AppCmd.exe tool provides a constant set of commands, with this set of commands, you can perform query operations and accomplish other tasks for supported object types, either by running these commands in section du or by combining commands to combine commands so that you can perform complex tasks and complete complex queries such as tables:
Object Name |
Description |
Site |
Managing Virtual Web Sites |
App |
Managing Applications |
VDir |
Managing Virtual Directories |
Appool |
Managing Application Pools |
Config |
Calendar General configuration file |
Wp |
Calendar work Process |
Request |
Managing HTTP Requests |
Module |
Managing Server Modules |
Backup |
Manage Server Configuration Backup |
Trace |
Manage failed request tracking logs |
Commands supported by the AppCmd.exe tool:
add Clear Configure Delete Inspect install list lock migrate recycle reset restore search set STA RT Stop Uninstall Unlock
Hint: The command is always in front of the object, and the property is always after the object, so you can create a structure that resembles a statement, in which the Appcmd.exe notifies the object to do something. List application Pool Set Configure application pool Add Add new application pool Delete Delete application pool start start application pool Stop stop application pool recycle recycle application pool 1, list all instances of an object Appcmd.exe List App 2, list unique object instances Appcmd.exe list App "Default Web site/" 3, List object instances that meet certain criteria Appcmd.exe list app/apppool.name: "Defa Ultapppool "4, listing the details of the object Appcmd.exe list app" Default Web site/"/text:* 5. Lists all XXX application pool applications Appcmd.exe list app/text:/ Apppool.name:XXX 6, List the configuration information of the website appcmd.exe list site "Default Web Site"/config 7, replace application pool Appcmd.exe set app "Default Web site/"/applicationpool:" XXX 8, add a new application pool Appcmd.exe add apppool/name: "XXX" 9, delete application pool Appcmd.exe Delete Apppool/app Pool.name: "XXX" 10, listing the details of all application pools Appcmd.exe list AppPool 11, query all application pool status started Appcmd.exe list Apppools/state:sta RTed 12, turn off the specified application pool Appcmd.exe stop apppool/apppool.name: "XXX" 13, open the specified application pool appcmd.exe start apppool/apppool.name: "xxx "14, monitoring the current request Appcmd.exe the list Request object can use attributes to find specific information by using the, you can return Web sites, application pools, worker processes, URLs, and requested information that have elapsed time (measured in milliseconds) that exceed the preset values. The properties used by the Request object include: request based on site ID appcmd.exe list REQUEST/SITE.ID:1 request based on application pool Appcmd.exe list Request/apppool.exe:defaul Tapppool request based on worker process Appcmd.exe list request/wp.name: "1044" request based on site name Appcmd.exe list request/site.name: "Default Web S ITE "request based on Process run time appcmd.exe list request/elapsed:" 1000 "15. Site backup and restore Backup site: Appcmd.exe Add backup backupname list backup: AP Pcmd.exe List Backup Recovery backup when you restore a backup, IIS stops running and overrides the status of the server. Once the configuration file is overridden, IIS restarts. If you do not want IIS to stop running and restart, you can use/stop:false. This allows you to manually stop IIS running at the appropriate time and manually restart IIS appcmd.exe restore backup/back.name: "XXX"/stop:false appcmd.exe restore Backup/back Up.name: "XXX" Delete backup Appcmd.exe relete backup XXX 16, list server Overall configuration information Appcmd.exe List config lists the default Web site configuration appcmd.exe list Config "Default Web site/" You can perform the Appcmd.exe list config "Defaul Web site/" When you need to display the configuration content for the default Web site/section:system.ne
T/settings get all available nodes Appcmd.exe list config-section:? 17, edit configuration node information EG1: Enable global IPv6 Appcmd.exe set confIg/section:system.net/settings-ipv6.enabled: "True" EG2: IPV6 is enabled in the global configuration and is now referenced in the default Web IPv6 Appcmd.exe set config http ://LocalHost "/section:system.net/settings-ipv6.enabe: false" Lists node collection appcmd.exe list config/section:httperrors edit node Set Together with eg: the 401 error page has "401". HTM "modified to" defaulterror.htm "deletes the 503 status code appcmd.exe set Config/section:httperrors/-[statuscode= by using the plus sign (+) or a minus sign (-) to add a live deletion element ' 503 '] appcmd.exe set config/section:httperrors/[statuscode= ' 401 '].path:defaulterror.htm 18, Lock and unlock configuration: APPCMD.E Xe unlock config "Default Web site"/section:system.web/authentication Lock: Appcmd.exe lock config "Default Web site"/se Ction:system.web/authentication 19, using pipeline to transfer XML data can create complex tasks using the/xml modifier in the Appcmd list, and can perform large-scale batch work. With the/xml modifier, you can export and save the results of a query to a file in a standard XML format so that other command-line tools or shell commands can use the XML file.
For example, to list all the enabled application pools and save the information in a standard XML file, execute the following command: Appcmd.exe list apppool/state:started/xml