2

I have developed an C# application that connects to a database on a different server. The connection string will be taken from the app.settings file.

Now as the application runs fine, my client (customer) would like to deploy the app to different client computers via a GPO. It is already working on my local computer and I can connect to the server (my server) because the app.settings will be installed correctly in the appropriate installation folder. But the value of the sql server in the app.settings is hardcoded in that file.

And due to the fact that I am not really aware of the SQL server name in the client environment I would like to give the client the possibility to setup and deploy the application with the server name as a parameter in the setup file.

Is that possible like run the setup script as "setup.exe -server 192.168.xxx.xxx"?

Many thanks!

  • [Command Line Arguments](https://msdn.microsoft.com/en-gb/library/aa288457(v=vs.71).aspx) – byxor Aug 23 '16 at 11:27

1 Answers1

2

You can add custom parameters to you installation project by adding custom screens with textboxes: .net Setup Project: How to pass multiple CustomActionData fields

Community
  • 1
  • 1
Marcel Theis
  • 303
  • 1
  • 12
  • Hi When adding text boxes to the installer screen then the user needs to provide the data. But that isn't the case. I would like to give the administrator (who deploys the application) the possibility to provide the data in a way where the user doesn't need to provide it in the installer process. – Ronny Drechsler-Hildebrandt Aug 23 '16 at 11:50
  • actually that are commandline parameters, if you install the msi in silent mode (as we do in our company), what is mostly done when installing remote. – Marcel Theis Aug 23 '16 at 12:01
  • OK. So it is possible to install the MSI package with command line parameters? If so, how can I have access to it within the installer to set the sql server name in the app.config then? Thanks for your help! – Ronny Drechsler-Hildebrandt Aug 23 '16 at 12:22
  • Take a look at the link I provided, there you can find a detailed discription adding CustomActionData – Marcel Theis Aug 23 '16 at 12:33
  • Thanks again. But in the link you have provided the custom data fields in the setup will be shown in the setup screen where the **USER** needs to provide the data. But that is not what I want to achieve here. Or can I pass those values in the command line as well? – Ronny Drechsler-Hildebrandt Aug 23 '16 at 13:20
  • 1
    Yes, you can! From the link you should go on to this: https://msdn.microsoft.com/en-us/library/2w2fhwzz%28v=vs.100%29.aspx (see answer in the link) and then to this: https://msdn.microsoft.com/en-us/library/system.componentmodel.runinstallerattribute%28v=vs.100%29.aspx – Marcel Theis Aug 23 '16 at 13:27
  • 2
    After another search I could find the solution at the following website: http://www.codeproject.com/Articles/16767/How-to-Pass-Command-Line-Arguments-to-MSI-Installe – Ronny Drechsler-Hildebrandt Aug 24 '16 at 08:18
  • 1
    Yes, that are the CustomActionData fields mentioned in the link. Beside entering them manually by the installing person, you are able to add them as commandline parameters to the installer. By the way, the link mentioned by you is the first one on google ;-) – Marcel Theis Aug 24 '16 at 08:21