How do I retrieve/pass back a property with AutoIt? - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

jbridges
Posts: 38
Joined: Fri Jun 09, 2006 12:36 am

How do I retrieve/pass back a property with AutoIt?

I want to be able to pick up a property that I set in a new dialog I create, then pass back a result. I tried picking up the property as an environmental variable in my AutoIt script - that did not work. What is the method of doing this?
jbridges
Posts: 38
Joined: Fri Jun 09, 2006 12:36 am

Re: How do I retrieve/pass back a property with AutoIt?

I found out the answer to the first part - how to retrieve a property. But, how would I export the result - and make a decision based upon it? The result can be an exit code but I dont want to exit the installer if non-zero. In my case, I want to pass a license key, check to see if it is valid, then pass back a good/bad code. Then, if "bad", to go back and tell the user to enter again.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: How do I retrieve/pass back a property with AutoIt?

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:

Code: Select all

DoAction       myaction.dll        AI_INSTALL
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
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”