我需要为我支持的应用程序实现一些版本控制,我可以将网站复制到c:\ inetpub \ wwwroot \ app_v2,然后从c:\ inetpub \ wwwroot \ app_v1切换虚拟目录。
有没有办法从命令行更改IIS中虚拟目录的物理路径?
编辑:
我发现在IIS7中,您可以使用appcmd在此页Change the Physical Path of Virtual Directory Content上使用此格式设置虚拟目录的物理路径。我一直在寻找更普遍的东西......
appcmd set vdir /vdir.name:string / physicalPath:string
然而,似乎没有IIS 6的等效。
答案 0 :(得分:6)
是的,请查看WMI脚本。
http://learn.iis.net/page.aspx/163/managing-applications-and-application-pools-on-iis-7-with-wmi/
http://www.aspfree.com/c/a/IIS/IIS-60-Getting-Information-Using-WMI/3/
尼克
答案 1 :(得分:2)
我今天遇到了同样的问题:“如何使用命令行更改IIS6 vdir的路径?”
WMI脚本是要走的路,所以我想我会发布我为此创建的vbs。
要使用它,只需传递vdir名称和路径即可。因此,如果我有一个名为“Web”的vdir并想要将路径更改为“d:\ theNewPath \ to \ Website”,那么我将在命令提示符中运行以下命令:
updateVDirPath web d:\theNewPath\to\Website
另外,要检查Vdir的路径,只需传递vdir名称:
updateVDirPath web
以下是更新VDirPath.vbs
的内容If WScript.Arguments.Count = 0 or WScript.Arguments.Count > 2 Then
WScript.Echo "To check the vDirs path, call updateVDirPath <vDir>" & vbCrLf & "To update the vDir's path, call updateVDirPath <vDir> <newPath>"
Else
set providerObj = GetObject("winmgmts://localhost/root/MicrosoftIISv2")
set IIsWebVirtualDirSettingObj = providerObj.get("IIsWebVirtualDirSetting='W3SVC/1/ROOT/" & WScript.Arguments(0) & "'")
If WScript.Arguments.Count = 1 Then
WScript.Echo "Current path is: " & IIsWebVirtualDirSettingObj.Path
Else
IIsWebVirtualDirSettingObj.Path = WScript.Arguments(1)
IIsWebVirtualDirSettingObj.Put_ ()
End If
End If