Targeting the .NET Framework Version and Bitness with AppCmd

AppCmd.exe and Configuration Editor are very useful tools for IIS 7.x administrators.  Today I had a situation come up where I wanted to use AppCmd to script the trust level for all framework versions.  It wasn’t immediately apparent how to target all framework versions, so I thought I would share my findings.


Changes to IIS are made to applicationHost.config or to a site’s web.config file(s).  If settings are targeted at integrated mode, classic mode, bitness or framework version, that is achieved by filtering modules and handlers using the preCondition property.  For example:

<add name="ManagedEngine64" preCondition="integratedMode,runtimeVersionv2.0,bitness64" image="...\Framework64\v2.0.50727\webengine.dll" />

However, changes to ASP.NET require that you update each configuration file for every framework version.  If you have ASP.NET 1.1, 2.0 and 4.0 on a 64-bit server, this means that you have five configurations to manage if you want to support all five combinations.

Here’s an example of the five paths to the config folders for the five paths mentioned above.  Note that ASP.NET 1.1 only has a 32-bit version.


To edit the ASP.NET config files, you can edit them directly in your favorite editor like Notepad, UltraEdit, Notepad++, etc.  That can be a lot of works and doesn’t allow you to automate it.  Alternately, you can use tools like Configuration Editor or AppCmd.exe.

Configuration Editor

Configuration Editor is a great tool to find out the syntax for AppCmd.  I often start with Configuration Editor when I want to generate C# or AppCmd syntax.  After you make a change with Configuration Editor you can click the Generate Script link and it will give you syntax for C#, JavaScript and AppCmd as shown in the image below. If you don’t have Configuration Editor already, you can obtain it from


Configuration Editor at the site, application or path level

In Configuration Editor you can make changes at the server level or site/app level.  If you make a setting at the site or application level, it either applies the setting in your site’s web.config file which works for all framework versions, or if it needs to make a change in the framework config files it will automatically know where to apply it based on the framework version defined on the application pool.

Configuration Editor at the server level

However, for a server level change you potentially have five files to target.  You can change the framework version that Configuration Editor uses with the “Change .NET Framework Version” link in the Actions pane.


Unfortunately this doesn’t allow you to change the bitness.  Hopefully we see that level of control in future versions.

There is a solution for AppCmd, and that’s what I needed for my situation today.  I asked Carlos Aguilar Mares for assistance since I couldn’t find the answer elsewhere.  My blog post is inspired by his answers so he gets the credit for the answers on how to target the framework versions.


With AppCmd you can target the framework version by using a combination of /clr:2 (or 4) and two different versions of AppCmd.exe.  AppCmd.exe doesn’t currently have a way to target the framework version, but there are two versions of AppCmd available for you, each targeting different bitnesses.  They are located at:

%windir%\System32\inetsrv\appcmd.exe (64-bit version)
%windir%\SysWOW64\inetsrv\appcmd.exe (32-bit version)

With this knowledge in hand, it’s easy to create powerful scripts to automate installations for you.  Following is my example of how to set the trust level for all configurations.  Take note of the path at the beginning and the /clr at the end.

c:\windows\system32\inetsrv\appcmd.exe set config  -section:system.web/httpHandlers /+"[path='example.axd',type='...',validate='False',verb='GET']" /commit:webroot /clr:2
c:\windows\system32\inetsrv\appcmd.exe set config -section:system.web/httpHandlers /+"[path='example.axd',type='...',validate='False',verb='GET']" /commit:webroot /clr:4
c:\windows\SysWOW64\inetsrv\appcmd.exe set config -section:system.web/httpHandlers /+"[path='example.axd',type='...',validate='False',verb='GET']" /commit:webroot /clr:2
c:\windows\SysWOW64\inetsrv\appcmd.exe set config -section:system.web/httpHandlers /+"[path='example.axd',type='...',validate='False',verb='GET']" /commit:webroot /clr:4

With this in mind, you have full flexibility to target any ASP.NET configuration location that you need.

No Comments