<p>I am developing a .NET WinForms application which relies on user.config to store various useful settings such as intranet web service URLs.  We would like to make it possible to import custom initial settings as part of the installation.  The use case for this is if a company has 100 machines they want to install the software on, and they should all have a reference to the intranet web service in question, this should not need to be set up manually on all the machines.</p>

<p>We are currently using a VS2008 setup project to generate the install package.</p>

<p>Our idea so far has been to enable the installer to make a custom initial .config file with the information (from a template), and then put that in place instead of the default one that the setup project installs.</p>

<p>However, I can't see a way to do this other than these few:</p>

<ol>
<li>Hardcode the executable name into a custom installer action (deriving from System.Configuration.Install.Installer), in order to use the ConfigurationManager class to determine the .config file path.  This would require manual changes to the installer if the executable name changes.</li>
<li>Roll our own configuration classes or file/folder hierarchy to store the settings.  This would basically bar us from the advantages of the isolation mechanism (which is also the obstacle here) that .NET provides, if I understand correctly.</li>
</ol>

<p>Does anyone know of any alternatives, or of ways to make the above two palatable?</p>

<p>I fear the answer may be "don't do this, it defeats the spirit of the mechanism, roll your own settings import mechanism".</p>

[{'answer_id': 77385, 'author': 'Shachar', 'author_id': 13897, 'author_profile': 'https://Stackoverflow.com/users/13897', 'pm_score': 1, 'selected': False, 'text': '<p>I know that\'s not exactly the answer you\'re looking for, but you should opt for a more "serious" installer. We\'re using Advanced Installer and it\'s a blast, does anything and everything you can think of.</p>\n'}, {'answer_id': 156816, 'author': 'Veldmuis', 'author_id': 18826, 'author_profile': 'https://Stackoverflow.com/users/18826', 'pm_score': 0, 'selected': False, 'text': '<p>If it is acceptable for you to hardcode at least one setting in the config file, you can use this to point to a database or web service or network file path where all the custom config settings can be stored.  Using System.Configuration.ConfigurationManager.OpenExeConfiguration() you can then update the config file from this location either on the first run or every time that the application starts up.</p>\n'}, {'answer_id': 163763, 'author': 'KovBal', 'author_id': 19998, 'author_profile': 'https://Stackoverflow.com/users/19998', 'pm_score': 2, 'selected': False, 'text': '<p>If you create this application for larger companies, then you should have a look at <a href="http://technet.microsoft.com/en-us/windowsserver/grouppolicy/default.aspx" rel="nofollow noreferrer">Group Policy</a>. Unfortunately, it\'ll bring your application back to the golden age of registry. I understand, that this would be a huge change in your program, but this is the way to this.</p>\n\n<p>However, if the web service\'s URL is the only thing, you have to setup this way, then GPO might be an overkill. In that case I would hardcode the executable\'s name.</p>\n'}]
['https://Stackoverflow.com/questions/75546', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2729/']