RepeatHost Business Hosting

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:

iis asp.net tab

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.