Asp.net
使用 IIs6 或 IIs7 的命令行更改 IIS 中虛擬目錄或站點的物理路徑
我需要為我支持的應用程序部署一些版本控制,我可以將站點複製到 c:\inetpub\wwwroot\app_v2,然後從 c:\inetpub\wwwroot\app_v1 切換虛擬目錄。
有沒有辦法從命令行更改 IIS 中虛擬目錄的物理路徑?
編輯:
我發現在 IIS7 中,您可以使用 appcmd 在此頁面上使用此格式設置虛擬目錄的物理路徑 Change the Physical Path of Virtual Directory Content。我一直在尋找更普遍的東西……
appcmd 設置 vdir /vdir.name:string /physicalPath:string
但是,似乎沒有 IIS 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/
缺口
我今天也有同樣的問題:“如何使用命令行更改 IIS6 vdir 的路徑?”
WMI 腳本是要走的路,所以我想我會發佈為此創建的 vb。
要使用它,只需傳遞 vdir 名稱和路徑。因此,如果我有一個名為“Web”的 vdir 並想將路徑更改為“d:\theNewPath\to\Website”,那麼我將在命令提示符下執行以下命令:
updateVDirPath web d:\theNewPath\to\Website此外,要檢查 Vdir 的路徑,只需傳遞 vdir 名稱:
updateVDirPath web這裡是updateVDirPath.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