代码之家  ›  专栏  ›  技术社区  ›  Brian Lyttle

vbscript/iis-如何为特定网站自动设置ASP.NET版本

  •  2
  • Brian Lyttle  · 技术社区  · 16 年前

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

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

    2 回复  |  直到 12 年前
        1
  •  6
  •   Community CDub    8 年前

    @ 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站点不能混合在同一个应用程序池中。

        2
  •  2
  •   Chris Miller    16 年前

    我找到了下面的脚本 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