【问题标题】:VBScript/IIS - How do I automatically set ASP.NET version for a particular websiteVBScript/IIS - 如何为特定网站自动设置 ASP.NET 版本
【发布时间】:2010-09-06 11:05:15
【问题描述】:

我需要在 IIS 6.0 上编写应用程序池和网站的创建脚本。我已经能够使用 adsutil.vbs 和 iisweb.vbs 创建这些,但不知道如何将我刚刚创建的网站的 ASP.NET 版本设置为 2.0.50727.0。

理想情况下,我想通过 adsutil.vbs 更新元数据库。我该怎么做?

【问题讨论】:

    标签: asp.net iis vbscript sysadmin administration


    【解决方案1】:

    我在 Diablo Pup 的博客上找到了以下脚本 posted。它使用 ADSI 自动化。

    '******************************************************************************************
    ' Name: SetASPDotNetVersion
    ' Description: Set the script mappings for the specified ASP.NET version
    ' Inputs: objIIS, strNewVersion
    '******************************************************************************************
    Sub SetASPDotNetVersion(objIIS, strNewVersion)
     Dim i, ScriptMaps, arrVersions(2), thisVersion, thisScriptMap
     Dim strSearchText, strReplaceText
    
     Select Case Trim(LCase(strNewVersion))
      Case "1.1"
       strReplaceText = "v1.1.4322"
      Case "2.0"
       strReplaceText = "v2.0.50727"
      Case Else
       wscript.echo "WARNING: Non-supported ASP.NET version specified!"
       Exit Sub
     End Select
    
     ScriptMaps = objIIS.ScriptMaps
     arrVersions(0) = "v1.1.4322"
     arrVersions(1) = "v2.0.50727"
     'Loop through all three potential old values
     For Each thisVersion in arrVersions
      'Loop through all the mappings
      For thisScriptMap = LBound(ScriptMaps) to UBound(ScriptMaps)
       'Replace the old with the new 
       ScriptMaps(thisScriptMap) = Replace(ScriptMaps(thisScriptMap), thisVersion, strReplaceText)
      Next
     Next 
    
     objIIS.ScriptMaps = ScriptMaps
     objIIS.SetInfo
     wscript.echo "<-------Set ASP.NET version to " & strNewVersion & " successfully.------->"
    End Sub 
    

    【讨论】:

      【解决方案2】:

      @Chris 在 ADSI 路上打败了我

      您可以使用 aspnet_regiis.exe 工具执行此操作。机器上安装的每个版本的 ASP.NET 都有这些工具之一。你可以掏钱 -

      这配置了 ASP.NET 1.1

      %windir%\microsoft.net\framework\v1.1.4322\aspnet_regiis -s W3SVC/[iisnumber]/ROOT
      

      这配置了 ASP.NET 2.0

      %windir%\microsoft.net\framework\v2.0.50727\aspnet_regiis -s W3SVC/[iisnumber]/ROOT
      

      您可能已经知道这一点,但如果您的计算机上有多个 1.1 和 2.0 网站,请记住将您要更改 ASP.NET 版本的网站切换到兼容的应用程序池。 ASP.NET 1.1 和 2.0 网站不会混合在同一个应用程序池中。

      【讨论】:

        猜你喜欢
        • 2011-03-09
        • 2011-07-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-28
        • 1970-01-01
        • 1970-01-01
        • 2016-01-02
        相关资源
        最近更新 更多