From: Patridge on
I am trying to find a way to add a sub-application to an existing site via
appcmd command line.

I have tried to derive the syntax from various examples of modifying and
adding site bindings but the XML I need to generate doesn't quite fit with
those examples. I would like to result in the addition of the the following
XML to applicationHost.config under an existing site ("SomeSite" in the
example calls): "<application path="/subdir"><virtualDirectory path="/"
physicalPath="{locationOfSubSite}\subdir" /></application>".

I have tried a number of variations on both "set config" and "add vdir" but
I cannot quite nail it down.

C:\>%windir%\System32\inetsrv\appcmd.exe set config "SomeSite"
/section:system.applicationHost/sites
/+"[name='SomeSite'].[path='/subapp'].[path='/',physicalPath='D:\inetpub\wwwroot\SomeSite\SubApplication']" /commitPath:apphost
==> "ERROR ( message:Cannot find requested collection element. )"

C:\>%windir%\System32\inetsrv\appcmd.exe add vdir /app.name:"SomeSite"
/path:"/subapp" /physicalPath:"D:\inetpub\wwwroot\SomeSite\SubApplication"
/commitPath:apphost
==> Creates a virtual directory on top of the sub-application directory in IIS

C:\>%windir%\System32\inetsrv\appcmd.exe add vdir
/app.name:"SomeSite/subapp" /path:"/"
/physicalPath:"D:\inetpub\wwwroot\SomeSite\SubApplication" /commitPath:apphost
==> "ERROR ( message:Must use exact identifier for VDIR object with verb
ADD. )"

If I could find a reference to the config syntax of brackets and periods,
especially regarding when to use a section name and when to use the attribute
breakdown, I would probably be able to work this out. Not finding such a
resource, though, I would appreciate any help I can get.