0

Background: I used Visual Studio setup project to deploy one of C# application to client windows server. While installing the application I need to setup a scheduled task in the server as well For this I used a Custom Action feature in the setup project. What I did is created a windows form with input fields and "ok" button and once user enter values and click on the "ok" button task will be created. I added this custom task in Install and Commit steps in Custom Action.

Issue : Everything works fine but when the created windows from shows, it lost the focuses even I used showDialog method to show the form. So always main setup window will active and users not see the popup form in background (see the attached image).But I can click on the popup window and make it activate. I tried with SetActiveWindow method also but no good result so far.

Simple what I need is to activate the popup window untill user action (default showDialog behavior). So here I'm looking for any help. enter image description here

Nayana Adassuriya
  • 23,596
  • 30
  • 104
  • 147

1 Answers1

1

If you want to get user input using custom UI during the MSI deployment best approach is to create the .wid extension files. this is the type of UI files that you see during the MSI installation(where you select the installation path etc). Enough though visual studio doesn't have features to create these UI files there are Microsoft tools you can use to create these files. One of the best tool is Orac.

Once you create the UI file, you have to place the file under C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\Deployment\VsdDialogs\1033 (it's where MSI picks the default UI files from)

After that you should be able to select your custom UI and inject it during any phase of installation cycle(beforeinstall, install, afterinstall etc). Then you can pass the value user has entered into the text field as a argument for installer class. Then you can read the value within the installer class using context parameter.

string value = Context.Parameters["ParameterName"];
Kurubaran
  • 8,696
  • 5
  • 43
  • 65
  • Actually I have gone through the method you mentioned before. But my issue was, If I need to validate user inputs, it is very difficult to configure it by using Orca. I tried to find any useful resource, but I couldn't. that's why I trying above method. If you know any sample code related to C# please let me know. thank you – Nayana Adassuriya Sep 30 '13 at 09:10
  • You can still do the validation on the value users has entered with the approach i have gievn, You can validate it and disply message from Installer class and you can also abort the installation if validation fails. – Kurubaran Sep 30 '13 at 09:50
  • Could you help me to refer any example. Because I'm facing to lack of information. – Nayana Adassuriya Sep 30 '13 at 09:56
  • Can you continue with creating custom .wid UI and incorporate it with your MSI project. I can help you if you come accross any issue, once you get the value of textbox from installer class you can validate it and show message to user just ShowMessage() will do, if validation fails you just throw general exception(throw new Exception();) which will abort the installation and revert all the changes. – Kurubaran Sep 30 '13 at 10:48
  • Thank you for your help. I created the custom dialog layout as I need successfully. Now I need to validate the three text fields at the click event of the `Next` button. I don't know how to do this. appreciate your help? – Nayana Adassuriya Oct 01 '13 at 02:06
  • @NayanaAdassuriya did you give id or name for those 3 textboxes when you created that .wid Ui file ? – Kurubaran Oct 01 '13 at 06:39