Setup and Deployment : Custom Action to Capture User Input


Users are allowed to pass Product Key while installing in .msi. During that we want to capture it for registration to avoid piracy.


When we use “Customer Information” dialog in “Start” action, it has “SerialNumberTemplate”. But capturing information from there is really tough as mentioned in the article So we have to use the “TextBoxes” dialog and get the data from there.


For sample test, I have created on Windows Forms Application “Deployment_SerialNumber”. There I have added InstallerClass called “InstallHelper.cs” with the below code


public partial class InstallerHelp : Installer


public override void Install(IDictionary stateSaver)



string strKey = Context.Parameters["KeyValue"];

string sPath = @"c:\Test.txt";

if (File.Exists(sPath))


File.WriteAllText(sPath, strKey);



Now I moved to Setup and Deployment Project which is in the same Solution. Added the Primary Output under Application Folder of File System. Pointed the Windows Application “Deployment_SerialNumber”.


Then from the Visual Studio menu I have moved to User Interface of Setup project.


Then in the “Start” section I have added TextBoxes(A) and placed between “Installation Folder” and “Confirm Installation”.


In the property window I made the other two text boxes to invisible.


Then moved to “Custom Actions” by VS menu,


Then under “Install” added the Project where I have the InstallHelper.cs class.


Then we have added the “Custom Action Data” to pass the user input through parameter. That is the catch and because of this we can capture it through string strKey = Context.Parameters["KeyValue"];

Notice the Property and the code. Both has “KeyValue”


One caution, The value you pass here cannot be with a space, it will fail (because you are passing parameter).