VBScript/IIS - How do I automatically set ASP.NET version for a particular website

吃可爱长大的小学妹 提交于 2019-12-23 22:18:46

问题


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.

Ideally I would like to adsutil.vbs to update the metabase. How do I do this?


回答1:


@Chris beat me to the punch on the ADSI way

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 -

This configures ASP.NET 1.1

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

This configures 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.




回答2:


I found the following script posted on Diablo Pup's blog. It uses ADSI automation.

'******************************************************************************************
' 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 


来源:https://stackoverflow.com/questions/20923/vbscript-iis-how-do-i-automatically-set-asp-net-version-for-a-particular-websi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!