IIS7.0 Appcmd command Detailed and timed restart of application pool and site Settings

Source: Internet
Author: User

IIS7.0 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".

Due to the need to periodically restart the application pool and site, the new colleague engaged in a scheduled task to perform the operation, I use the colleague document further summary.

1. Set up a batch file file to stop and start the service. The batch file has the extension:. bat or. cmd.

Colleague's approach:

For example, restarting the application pool and the site are all named Intrawebservice:

Stop, wait 60 seconds, start, save the result after executing the command to C:\Users\jcheng\restart.log

Appcmd Stop Apppool/apppool.name:intrawebservice >> C:\Users\jcheng\restart.log

Appcmd Stop site/site.name:intrawebservice>> C:\Users\jcheng\restart.log

Ping-n 60-w 1000 192.168.255.255

Appcmd Stop apppool/apppool.name:intrawebservice>> C:\Users\jcheng\restart.log

Appcmd Stop site/site.name:intrawebservice>> C:\Users\jcheng\restart.log

2. Set up scheduled Tasks to execute bat files regularly.

Network Baidu:

Use the WIN7 Task Scheduler function to execute the program regularly

Everyone in the use of the computer may encounter some need unattended to let the computer perform the task after the scheduled shutdown of the situation, in the Win7 system, we can use the task scheduling function combined with shutdown command flexibility to set the task schedule, so that the Win7 system implementation of timing automatic execution, And you can customize your daily tasks so that Win7 is executed automatically at a specified time frequency.

We click the Start button in the Win7 system, select Open All Programs-accessories-System Tools, find Task Scheduler to open the WIN7 system's task scheduling settings panel. You can also click the Win7 Start button to enter a task plan in the Multifunction search box and open it directly from the search results.

The premise is that you've written a startup script. The script is as follows:

IIS7.0 Appcmd command Detailed and timed restart of application pool and site Settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.