Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using VSTS 2008 + C# + .Net 3.5 + IIS 7.0. I want to using appcmd to add a new web site, my scenario is like this.

  1. All my web site files are under folder c:\template;
  2. I want to add my new web site as a virtual directory under default web site, the virtual directory is called "testsite1";
  3. I want to use the default application pool (or the application pool which default web site is using).

I have stuied appcmd for quite some time, but cannot figure out. Maybe either I am too stupid or because IIS 7.0/appcmd is new, help information is limited. :-)

Appreciate if anyone could let me know how to complete my deployment task using appcmd?

thanks in advance, George

share|improve this question
I had the same issue and posted it on the MSDN forums (with no reply yet, but I will cross it here should an answer show up there). It seems like one could work out issues like this on their own if only there was explicit documentation about the funky square-bracket syntax they use for adding new elements. – patridge Jul 19 '10 at 19:01
up vote 1 down vote accepted

If you're trying to do this from code, I would recommend Microsoft.Web.Administration instead of appcmd. However, if you're doing it from the command line then appcmd is what you need.

Additionally if you have access to the server, why are you using vdirs for sites instead of full sites? You may find that full sites are cleaner. It depends on your situation, of course.

To do it with appcmd, it would be something like this:

  • First, make sure that the folder is created. You can do that with the old command line 'md'
  • Then create the 'application'. It will use the default app pool, not the one of its parent. It's a bit more work to figure out the app pool of the parent first. It would be something like:

    appcmd add app /"sitename" /path:/foldername

  • Then create the 'vdir'.

    appcmd add vdir /"sitename/foldername" /path:/ /physicalpath:c:\inetpub\wwwroot\foldername

share|improve this answer
Thanks, question answered! – George2 Oct 25 '09 at 10:49
Is there a way to do this as described in the OP, though? I have a situation where I am working to automate the creation of a site already in use that does that very situation (the appcmd equivalent right-clicking a site subdirectory and saying "Convert to Application" within IIS). – patridge Jul 19 '10 at 19:16
Hi Patridge. What's OP? – Scott Forsyth - MVP Jul 27 '10 at 13:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.