I need to script the creation of app pools and websites on IIS 6.0. I have been able to create these using adsutil.vbs and iisweb.vbs, but don't know how to set the version of ASP.NET for the sites I have just created to 2.0.50727.0.
我需要在IIS 6.0上编写应用程序池和网站的脚本。我已经能够使用adsutil.vbs和iisweb.vbs创建这些,但不知道如何将我刚刚创建的站点的ASP.NET版本设置为2.0.50727.0。
Ideally I would like to adsutil.vbs to update the metabase. How do I do this?
理想情况下,我想adsutil.vbs更新元数据库。我该怎么做呢?
2 个解决方案
#1
6
@Chris beat me to the punch on the ADSI way
@Chris在ADSI方式上打败了我
You can do this using the aspnet_regiis.exe tool. There is one of these tools per version of ASP.NET installed on the machine. You could shell out to -
您可以使用aspnet_regiis.exe工具执行此操作。计算机上安装的每个ASP.NET版本都有一个这样的工具。你可以掏出来 -
This configures ASP.NET 1.1
这配置ASP.NET 1.1
%windir%\microsoft.net\framework\v1.1.4322\aspnet_regiis -s W3SVC/[iisnumber]/ROOT
This configures ASP.NET 2.0
这配置ASP.NET 2.0
%windir%\microsoft.net\framework\v2.0.50727\aspnet_regiis -s W3SVC/[iisnumber]/ROOT
You probably already know this, but if you have multiple 1.1 and 2.0 sites on your machine, just remember to switch the website you're changing ASP.NET versions on to compatible app pool. ASP.NET 1.1 and 2.0 sites don't mix in the same app pool.
您可能已经知道这一点,但如果您的计算机上有多个1.1和2.0站点,请记住将您正在更改ASP.NET版本的网站切换到兼容的应用程序池。 ASP.NET 1.1和2.0站点不会混合在同一个应用程序池中。
#2
2
I found the following script posted on Diablo Pup's blog. It uses ADSI automation.
我在Diablo Pup的博客上发现了以下脚本。它使用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
#1
6
@Chris beat me to the punch on the ADSI way
@Chris在ADSI方式上打败了我
You can do this using the aspnet_regiis.exe tool. There is one of these tools per version of ASP.NET installed on the machine. You could shell out to -
您可以使用aspnet_regiis.exe工具执行此操作。计算机上安装的每个ASP.NET版本都有一个这样的工具。你可以掏出来 -
This configures ASP.NET 1.1
这配置ASP.NET 1.1
%windir%\microsoft.net\framework\v1.1.4322\aspnet_regiis -s W3SVC/[iisnumber]/ROOT
This configures ASP.NET 2.0
这配置ASP.NET 2.0
%windir%\microsoft.net\framework\v2.0.50727\aspnet_regiis -s W3SVC/[iisnumber]/ROOT
You probably already know this, but if you have multiple 1.1 and 2.0 sites on your machine, just remember to switch the website you're changing ASP.NET versions on to compatible app pool. ASP.NET 1.1 and 2.0 sites don't mix in the same app pool.
您可能已经知道这一点,但如果您的计算机上有多个1.1和2.0站点,请记住将您正在更改ASP.NET版本的网站切换到兼容的应用程序池。 ASP.NET 1.1和2.0站点不会混合在同一个应用程序池中。
#2
2
I found the following script posted on Diablo Pup's blog. It uses ADSI automation.
我在Diablo Pup的博客上发现了以下脚本。它使用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