2017-03-16 29 views
1

這是很容易設置每個站點的環境變量在IIS管理器:如何使用appcmd.exe在IIS上爲每個站點設置環境變量?

IIS

我在尋找一種方式是使用Appcmd.exe的,所以我可以包括這在我的安裝腳本做。

我得到的最接近是這樣的:

C:\>C:\Windows\System32\inetsrv\appcmd.exe set config "dashboard" -section:system.webServer/aspNetCore /environmentVariables.[name='foo',value='bar'] /commit:apphost 

- >儀表盤是我的網站的名稱。

但這個命令將返回該錯誤:

ERROR(消息:找不到請求集合元素)

回答

1

您可能已經琢磨出來了,但這種格式應該工作:

appcmd.exe set config "dashboard" -section:system.webServer/aspNetCore /+"environmentVariables.[name='foo',value='bar']" /commit:apphost