Hi,
I tried picking up the property as an environmental variable in my AutoIt script - that did not work.
Please note that environment variable cannot be used by the same process which creates it. Therefore, your custom action cannot use an environment variable if it is launched by the installation which creates the variable.
I'm afraid that you cannot get the result of an EXE custom action, therefore I'm not sure if this is the correct approach. What you need can be done with an EXE only if you can somehow modify it to write it's result in the registry or a file.
Another way of verifying the license is to use a C++ DLL which will get and set installer properties by using the
MsiGetProperty and
MsiSetProperty functions:
Please note that we have an
example for a C++ DLL custom action.
In order to accomplish what you need by using a C++ DLL custom action you can follow these steps:
- go to the "Custom Actions" page and add the DLL as a custom action under "UI Custom Actions"
- go to your custom dialog and select the "Next" button
- select the "Published Events" tab and create a new "DoAction" control event which looks like this:
This control event will run your custom action when the "Next" button is pushed. The custom action will use the "MsiGetProperty" function to get the property of the edit box control (the license key). Also, it can use the "MsiSetProperty" function to set another property which will be used by the installer to determine if the key is valid or not.
If you want to make sure that the user cannot go to the next dialog until he inputs a valid license key, you can use another custom action:
- go to the "Custom Actions" page and create a new "ScriptInline" custom action under "UI Custom Actions"
- set the "Script Text" field to
MsgBox "Invalid Key."
- set this custom action as a "DoAction" control event for the "Next" button on your custom dialog
- set the condition for this control event to the property set by the DLL custom action (for example "NOT VALID", where "VALID" is the property set by the DLL custom action)
- set the same condition for the "NewDialog" control event on your custom dialog in order to prevent the user from seeing the next dialog
To do this by using an EXE you first must find a way to pass to it the property of the edit box. This can be done by passing it as a parameter in the command line of the custom action (if the EXE supports this type of parameters) or by using the registry.
Secondly, the EXE must return a value which will be used by the installer to determine if the license key is valid or not. Unfortunately, Windows Installer does not support interpreting the actual return value of the EXE (it must return 0 for success), therefore the EXE must write some information to the registry or to a file. This information can be then read through another custom action which will set a property (VALID).
Regards,
Cosmin
FOLLOW US
Get the latest news in Application Packaging