Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing web.config from command line

I have an ASP.NET application running under IIS. I'd like to be able to change one of the web.config values in Application Settings. I know it's possible to change it programmatically as described in this answer but I'm wondering if the same thing can be accomplished from the command line.

The IIS 7 Manager allows application settings and connection strings (among other options) to be changed. My hope is there is a way to do the same via the command line for IIS 6 and/or 7.

like image 444
Matthew Jacobs Avatar asked Dec 08 '10 14:12

Matthew Jacobs


People also ask

How do I get to Web config?

Click on Websites and Domains tab and click Show More at the bottom of the page. Click the icon for File Manager. Click on your web. config.

Does machine config override Web config?

The machine. config file file is at the highest level in the configuration hierarchy while Web. config file is to override the settings from the machine. config file.

Where is Web config configuration file?

The Web. Config file is used to configure Oracle Web Application functionality. This file is typically installed in the c:\Inetput\wwwroot\WebApp directory.


1 Answers

You can use AppCmd.exe which is included with IIS 7.0 and above, in fact Configuration Editor in IIS Manager will automatically generate the command line for you, for example here it will set the test key to NewValue for the /TestApp inside Default Web Site:

appcmd.exe set config "Default Web Site/TestApp" -section:appSettings /[key='test'].value:"NewValue"
like image 166
Carlos Aguilar Mares Avatar answered Sep 30 '22 07:09

Carlos Aguilar Mares