Change IIS ASP.NET Framework Version Programatically
I searched a good deal for a simple and easy way to change the target ASP.NET framework version for a Virtual Directory in IIS. To manually do this, you would normally open IIS and right-click the Virtual Directory you wanted to configure settings for. Then select Properties and you would be presented with a dialog like this:

To configure this setting programatically, you can use the application:
aspnet_regiis.exe
Here is the command to set a virtual directory to a specific framework version:
\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis.exe -s "w3svc/1/root/MyVirtualDirectoryName"
Where "MyVirtualDirectoryName" is the name of the virtual directory that you are changing settings for.
Here is a snippet of VBScript that runs changes the IIS ASP.NET framework version when run. This could be included in an installer or used to easily configure a server automatically:
Set WshShell = WScript.CreateObject("WScript.Shell")WshShell.Run("\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis.exe -s " & Chr(34) & "w3svc/1/root/WBID" & Chr(34), 1, TRUE)Save this script in a text file with a .vbs extension, then double click it to run the script.
Popular Articles
Last viewed:
- Windows Server 2003 Configure RRAS (Routing and Remote Access Service) Site to Site VPN
- Data Access Layer using SqlDataReader and C# - Joins
- Performance benchmarks for LINQ vs. SqlDataReader, DataSet - LINQ Compiled Queries: Part 2
- GridView ObjectDataSource LINQ Paging and Sorting
- Ajax - Exception has been thrown by the target of an invocation
- How to localize a BoundField / TemplateField HeaderText

Recent comments
13 hours 50 min ago
1 day 13 hours ago
3 days 14 hours ago
4 days 4 hours ago
4 days 14 hours ago
4 days 20 hours ago
5 days 34 min ago
1 week 21 hours ago
1 week 1 day ago
1 week 4 days ago