如何使用appcmd.exe在IIS上为每个站点设置环境变量? [英] How to set environment variables per site on IIS using appcmd.exe?
本文介绍了如何使用appcmd.exe在IIS上为每个站点设置环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在IIS管理器上为每个站点设置环境变量非常容易:
It is very easy to set environment variables per site on IIS Manager:
我正在寻找一种使用appcmd.exe的方法,以便可以将其包含在我的安装脚本中.
I looking for a way to do it using appcmd.exe so I can include this in my install script.
我最接近的是:
C:\>C:\Windows\System32\inetsrv\appcmd.exe set config "dashboard" -section:system.webServer/aspNetCore /environmentVariables.[name='foo',value='bar'] /commit:apphost
->仪表板是我网站的名称.
-> dashboard is my site's name.
但是此命令返回此错误:
But this command returns this error:
错误(消息:找不到所需的收集元素.)
推荐答案
您可能已经知道了,但是这种格式应该可以工作:
You may have figured it out already, but this format should work:
appcmd.exe set config "dashboard" -section:system.webServer/aspNetCore /+"environmentVariables.[name='foo',value='bar']" /commit:apphost
这篇关于如何使用appcmd.exe在IIS上为每个站点设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文