如果我在我的服务器上运行以下命令:
%windir%\system32\inetsrv\AppCmd.exe list site
我得到这个输出:
SITE "MyCompany.MyProject.WebRole_IN_0_Web" (id:1273337555,bindings:https/555.555.555.555:443:,state:Started)
我怎样才能得到的网站名称:
MyCompany.MyProject.WebRole_IN_0_Web
是一种讨厌的stringparsing我唯一的select? 该服务器是一个Windows Azure实例。
得到它了:
appcmd list site /text:name
给你这个:
MyCompany.MyProject.WebRole_IN_0_Web
帮助描述了这是如何工作的:
/text<:value> Generate output in text format (default). /text:* shows all object properties in detail view. /text:<attribute> shows the value of the specified attribute for each object.
我通过调用这个name是正确的属性:
appcmd list site /xml
其中以XML格式返回(包括属性名称):
<?xml version="1.0" encoding="UTF-8"?> <appcmd> <SITE SITE.NAME="MyCompany.MyProject.WebRole_IN_0_Web" SITE.ID="1273337555" bindi gs="https/555.555.555.555:443:" state="Started" /> </appcmd>
如果您正在寻找使用AppCmd启动任务configuration站点/应用程序池,请查看我最近的post:
http://mvolo.com/configure-iis-websites-windows-azure-startup-tasks-appcmd/
这包括如何find要编辑的站点/应用程序池,以及如何在创build站点/应用程序configuration之后运行任务,而不是之前。
希望这可以帮助。