IIS 7/7.5 .net configuration settings using appcmd.exe and IIS Manager

Just recently I came across an issue where customer was using appcmd.exe to make changes to the Application Settings and Configuration Settings he had made using IIS Manager. I am using Application Settings for this post but it holds true for all the ASP.NET settings from IIS Manager.

Application Settings using IIS Manager first at the Server Level, in our example it’s Sample


the setting gets reflected in web.config file in C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG folder.


Now, creating the new application settings on the Default Web Site, in our example it’s Sample2.


An entry is created in the web.config file at the website’s home directory, in our example its C:\inetpub\wwwroot folder.


If you create a new Application Settings at a virdir level, a new web.config will be created with the entry.

Now, the customer was following the article IIS 7.0: Remove an Application Setting and using appcmd.exe he wanted to remove the first entry i.e. Sample

The command he used as per the article was: appcmd.exe set config /commit:MACHINE /section:appSettings /-“[key=’Sample’,value=’1’]”



So, what’s going wrong?

Here the command is looking for the appSettings parameter and the key in MACHINE i.e. machine.config but it can not find it and hence the error. We now know the key is created in web.config, so what is the command to make the changes in web.config?

The correct command is: appcmd.exe set config /commit:WEBROOT /section:appSettings /-“[key=’Sample’,value=’1’]”


Check the IIS Manager and the entry is now removed.

Similarly, to remove appSettings from Default Web Site, the command is: appcmd.exe set config “Default Web Site” /section:appSettings /-“[key=’Sample2’,value=’2’]”


And to remove appSettings from NewVirDir i.e. the virtual directory under Default Web Site, the command is: appcmd.exe set config “Default Web Site/NewVirDir” /section:appSettings /-“[key=’Sample3’,value=’3’]”


Now, let’s create appSettings using appcmd.exe using the different variant’s and see where they get reflected


Machine.config in C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG


Web.config in C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG


applicationHost.config in C:\Windows\System32\inetsrv\config, since applicationHost.config is the global configuration file for IIS


applicationHost.config in C:\Windows\System32\inetsrv\config. The above command does not make much sense as it is not specific to Default Web Site and since it’s reflected in applicationHost.config it will apply for all web sites/virdir on the server which inherits the setting.


web.config in C:\inetpub\wwwroot folder


Comments (0)