I need to change the physical path of a web site through the command line via the appcmd.exe tool, but I can\'t figure out the syntax. Can someone help?
To get a list of virtual directories by site and app name to help ensure you are attempting to set the right thing.
C:\Windows\System32\inetsrv\appcmd.exe list apps /config /xml
optionally pipe that |more
and/or mode con cols=160
this regex pulled out the parts I wanted
var q= from siteApp in config.XPathSelectElements("appcmd/APP")
let appName=siteApp.Attribute(XNamespace.None+"APP.NAME").Value
from app in siteApp.XPathSelectElements("application")
let appPath=app.Attribute(XNamespace.None+"path").Value
let pool=app.Attribute(XNamespace.None+"applicationPool").Value
let vd=app.XPathSelectElements("virtualDirectory[@path]")
let virtuals=vd.Select (v => new{VirDir=v.Attribute(XNamespace.None+"path").Value,PhysicalPath=v.Attribute(XNamespace.None+"physicalPath").Value})
let xvirtuals=virtuals.Select (v => new{ VirDir=v.VirDir,
PhysicalPath=v.PhysicalPath,
EnvRoot=v.PhysicalPath.ToString().StartsWith("%")})
select new{AppName=appName,AppPath=appPath, Pool=pool,Virtuals=xvirtuals};
so then for a specific site it becomes
appcmd.exe set vdir "DefaultWebSite/jms" -physicalPath:"c:\inetpub\wwwroot\mytargetPath"
here's the variable substitutions:
appcmd.exe set vdir "
+ appName + virt.VirDir + " -physicalPath:"
+ targetPath+"
and to look at the config settings for just that site:
C:\Windows\System32\inetsrv\appcmd.exe list apps /config /xml /path:/jms
another usage to be aware of:
C:\Windows\System32\inetsrv\appcmd.exe list apps /metadata /config:* /xml