Introduction
The appcmd.exe is a single command, used to manage IIS 7 and above. It is used to manage the Server without using a graphical administration tool. The appcmd is located in C:\Windows\System32\inetsrv (%systemroot%\system32\inetsrv\) directory. By default, it will not add into environment variable.
Key Features
- Creating and configuring the sites.
- To list the running worker process.
- Backup and restoring the site configuration.
- Retrieve the information about the Application pools.
Object Types
Syntax
- appcmd <objecttypes> <parameters>
- set path=%path%;%systemroot%\system32\inetsrv;
To list all the sites, use the command, given below:
To get the details of a specific site binding and status (stopped/start), use the command, given below:
- appcmd list site "Default web site"
To list all the sites, which had been stopped, use the command, given below:
- appcmd list sites /state:Stopped
To add a new site, use the command, given below:
- appcmd add site /name:"added using appcmd" /bindings:"http/*:81:localhost" /physicalPath:"D:\test"
To add an https binding to the site, use the command, given below:
- appcmd set site /site.name:"added using appcmd" /+bindings.[protocol='https',bindingInformation='127.0.0.1:444:localhost']
To list all the applications, use the command, given below:
To change an application pool, use the command, given below:
- appcmd set app "added using appcmd/app1" /applicationPool:appcmdpool
To view the application pool details including the username and password of the app account, use the command, given below:
- appcmd list apppool "MyAppPool" /text:*
Backup
- appcmd add backup
- appcmd add backup "locahostbkup"
- appcmd list backup
- appcmd delete backup "backup name"
Restore
- appcmd restore backup "locahostbkup "
- appcmd restored configuration from backup "locahostbkup"
To view the list of the worker process, which will help us to attach the debugger in Visual Studio, use the command, given below:
To view the list of the physical path, use the command, given below:
- appcmd list vdirs /text:physicalPath
To start and stop the sites, use the command, given below:
- appcmd start site "Default web site"
- appcmd stop site "Default web site"