问题
I'm using appcmd
to create a new virtual directory in IIS8. The syntax for this is:
appcmd add vdir /app.name:<NAME> /path:<PATH> /physicalPath:<PHYSICAL-PATH>
This works fine. Now I need to set some credentials; this is easy in the GUI (virtual dir > basic settings > connect as). When I set this, I can see in my applicationHost.config
file that it is updating an XML entry. So I should be able to set that manually with appcmd
. I'm struggling with the syntax to navigate to the right XML element so I can set the attribute userName
and add the attribute password
.
Here is my XML:
<sites>
<site name="EXAMPLESITE" id="4">
<application path="/" applicationPool="EXAMPLEPOOL">
<virtualDirectory path="/" physicalPath="c:\wwwroot\" userName="" />
<virtualDirectory path="/upload" physicalPath="\\SOME-COMPUTER-ON-NETWORK\upload" userName="" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80" />
</bindings>
</site>
</sites>
回答1:
This should work:
appcmd set vdir /vdir.name:"EXAMPLESITE/upload" /userName:user /password:password
来源:https://stackoverflow.com/questions/18912419/iis-appcmd-syntax-for-setting-credentials-for-virtualdirectory