【问题标题】:change physical path for virtual directory or site in IIS using command line for IIs6 or IIs7使用 IIs6 或 IIs7 的命令行更改 IIS 中虚拟目录或站点的物理路径
【发布时间】:2010-10-14 09:20:18
【问题描述】:

我需要为我支持的应用程序实施一些版本控制,我可以将站点复制到 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 的等价物。

【问题讨论】:

    标签: asp.net iis deployment scripting appcmd


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2013-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-17
      • 2010-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多