Purpose
Users are allowed to pass Product Key while installing in .msi. During that we want to capture it for registration to avoid piracy.
Challenges
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 http://support.microsoft.com/kb/253683/en-us. So we have to use the “TextBoxes” dialog and get the data from there.
How
For sample test, I have created on Windows Forms Application “Deployment_SerialNumber”. There I have added InstallerClass called “InstallHelper.cs” with the below code
[RunInstaller(true)]
public partial class InstallerHelp : Installer
{
public override void Install(IDictionary stateSaver)
base.Install(stateSaver);
string strKey = Context.Parameters["KeyValue"];
string sPath = @"c:\Test.txt";
if (File.Exists(sPath))
File.Delete(sPath);
File.WriteAllText(sPath, strKey);
}
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). Namoskar!!!
PingBack from http://microsoft-sharepoint.simplynetdev.com/setup-and-deployment-custom-action-to-capture-user-input/
hi, tnx for this! i do have a couple of questions more though, if you could respond to my email, i'd be glad to discuss my inquiry, and your help would be so much appreciated! thank you!
exavier666@gmail.com
Useful stuff...
Well Explained!
Very useful, finally one i understood ;)
Thanks ! Very nice, Step by Step explanation, made my life easier !
if(strKey=="123")
else
///Show message to user , keycode that you entered is wrong one Please enter the correct One
Can I do like this .How can i do this ? Please Any one Help me out.
With Thanks ,
Ananthi Kasivel