Configure IIS 7 from the command line using Appcmd.exe - Part 1
This series will introduce how to use the IIS 7.0 command line called AppCmd.exe to query objects on the web server and display the output as text or XML.
In this series, I will show you how to use the new IIS 7.0 command line called AppCmd.exe to query objects on the web server and display the output as text. or XML.
Introduce
IS 7.0 provides a new command line tool, AppCmd.exe, that allows you to configure and query objects on your web server, then display the output as text or XML. In the first part of this series, we will show you what this tool is, how to use it, and how to perform common IIS administrative tasks such as creating new sites, stopping them. or start services and view the status of the site.
What can AppCmd.exe do with IIS administration?
AppCmd.exe allows you to perform all typical management functions using the CLI instead of the GUI. For example, here are some things that AppCmd.exe can do:
- Start and stop IIS web site
- Create applications, virtual directories and IIS websites
- Displays the running of IIS processes and lists the currently executing requirements
- Import, export and search ASP.NET IIS configurations
The better you use the output of an AppCmd.exe command, combine it with the logic script and use it to execute another AppCmd.exe command, the more power you will create for the application. In other words, while using AppCmd.exe to perform a certain command or placing that command on a Shortcut on the Desktop to make a good command to use is very useful, you can create a lot of functions. another by using AppCmd.exe in more complex IIS admin scripts.
These are just some typical applications for using AppCmd.exe:
- Start & Stop IIS sites from the command line
- Create a new IIS website or virtual directory (or make a change to IIS configuration)
- Backup IIS configuration
- Export IIS configuration
How to use AppCmd.exe
There are a few things you need to know about using AppCmd, even before you execute the AppCmd.exe command first.
- You must have IIS 7.x installed to support AppCmd.exe commands
- Know where the AppCmd.exe command is located because it is not in the default path. To run AppCmd.exe, you can use the way to change the directory to % windir% system32inetsrv or add that directory to your path variable. On our Windows 2008 server with the default installation. AppCmd.exe is located in C: WindowsSystem32inetsrv.
Like other Windows commands, you can use the basics of using commands by typing AppCmd.exe /?
You will see the layout of the command in general as follows:
APPCMD (command) (object-type) > *
Note: Not too worried about the complexity of this command - AppCmd.exe is easy to use. We will show you how to use it.
The basic commands used with AppCmd.exe are start, stop, list, add, delete, and set . Typically each of these commands will be used with an object type that you will require AppCmd.exe to perform its desired function.
The types of objects here are:
- Site - IIS virtual site
- App - IIS application
- Vdir - IIS virtual directory
- Apppool - IIS application pool
- Config - IIS general configuration
- Backup - IIS server configuration backups (you can also use the restore command)
- Wp - IIS worker processes
- Request - active HTTP requests
- Modules - IIS server administration modules
- Trace - IIS server trace logs
As you can see, there are many things you can do with AppCmd.exe, but it is not that difficult if you use help.
Use AppCmd.exe easily with help
We said that AppCmd.exe /? It will allow you to get help on AppCmd.exe. You can get information about object types by typing appcmd (object) /?
Here is an example:
You can also get more help information for different commands on each and every type of object. This means that there is a lot of help here for you. With 10 different object types and at least 3+ commands for each type (list, add and delete are regular commands), there are more than 30 different help files available. Here's an example of how to use help, which helps us know what can be done with the add command and the vdir command together:
Figure 2: Get help information with AppCmd.exe add and vdir options
If using help '/?' and listing step-by-step commands will give you instructions on how to perform any tasks you want to perform with AppCmd.exe.
5 ways you can use AppCmd.exe to make IIS website administration tasks easy
Ensure that everything can be done in the IIS management MMC (GUI) can be done with AppCmd.exe at the command prompt, but the GUI interfaces also have its drawbacks. To put a few names - with the GUI you cannot perform repetitive tasks (like a Windows Desktop Shortcut) nor can you use the output from an AppCmd.exe output and send it to an AppCmd Action.
Here are 5 ways to use AppCmd.exe to make your IIS website administration task easier:
1. Start and Stop IIS websites from the command line
This is indeed a simple task if you don't know your site's name, just do it:
Appcmd list sites
Figure 3: List sites using AppCmd.exe
Now you will know what sites you have and can start or stop IIS web sites as follows:
Appcmd start sites 'Default Web Site'
(or any site you want to start)
Figure 4: Start Website with AppCmd.exe
That way, it's easy to stop a website.
2. Add a new website
Adding a new website is also easy. Just use:
Appcmd add sites / name: 'Dave's Site' / id: 12 /bindings:http://mysite.com:80
As follows:
Figure 5: Adding a website with AppCmd
This way only adds a new website, that website may not be as complete as a site added in the GUI unless all command options are added then an application is added to it. To get the full functionality of the IIS site, use the following command:
AppCmd add site / name: ddsite / id: 99 / bindings: http / *: 81: / physicalPath: C: ddsite
AppCmd add app /site.name:DDSite / path: / ddapp / physicalPath: C: sitesddsite
3. List the objects with certain information
Using the listed command is easy. We showed you how to list your website running on the server in way 1 above. Note in the output that you can see that the site may be running or not running (the status of the sites). You can list all objects (like site) with certain information. For example, this command will list all sites that are stopped. Here is an example of how to do it:
Figure 6: Shows all IIS websites that have a certain status
4. Backup IIS configuration
AppCmd.exe can backup IIS configuration using the add backup command . You can also list your commands using the list backup and restore backup commands that can bring the backup data back to where it is needed with the command.
Below you can see that we have backed up our IIS configuration and then list what backups are available after that.
Figure 7: Backup the IIS configuration
5. Report on IIS configuration
AppCmd has the power to report IIS configurations and export the configuration to a text file. To do that, simply run:
Appcmd list site 'sitename' / config
This is what the output of the implementation process:
Figure 8: List IIS website configuration
Conclude
AppCmd.exe is indeed a command line tool for useful for IIS 7.x. AppCmd.exe can say that all IIS website configuration tasks can be done from the command line. It is a powerful support for Windows / IIS web administrators to know how to use it correctly to quickly perform common IIS tasks. In this article, you not only know what AppCmd.exe is but also know all that it can do for you in this way.
You should read it
- Netbook configured to play Acer Full HD video
- There are PUBG Mobile Lite for weakly configured phones
- How to create a multi-configured ghost for Win 7 with SPAT
- 10 reasons why IPsec VPN failed
- Improvements in ASM
- Tricks to optimize RAM memory to help the computer run smoother
- Fix problems in shared networks - Part 1
- Netbook 'strange' Asus N10
- What's new with Bphone A85 5G: Snapdragon 8 chip, unchanged design
- Binder and Malware (Part 3)
- What's new with Bphone A50: Thinner bezel design, coming out in December
- Smartbook runs Toshiba 8-hour Android 2.1 battery