Custom action to capture textbox data and send to server? - 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!

charlie
Posts: 3
Joined: Thu Nov 15, 2007 1:45 am

Custom action to capture textbox data and send to server?

Hi there,

I posted a question a little while ago - http://www.advancedinstaller.com/forums ... hp?p=11510

Basically, during installation there is an extra setup dialog which asks the user to enter their company name. I then need to somehow collect this data so that I know which companies have installed the software we have sent to them on disk.

I'm open to any suggestions, but I thought it might be easiest to write this data to the update server, seeing as it's connecting to it for updates anyway? A text file would be fine, even a separate text file for each user, it really makes no difference.

Does anyone have any idea how to achieve this? I'm not a seasoned programmer, so creating a "custom action" has proved a bit tricky, but if anyone could offer some examples of code I'd be very grateful and would certainly be eager to try and modify it to suit my specific needs.

Thanks in advance for your help :)

- Charlie
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom action to capture textbox data and send to server?

Hi Charlie,
but I thought it might be easiest to write this data to the update server, seeing as it's connecting to it for updates anyway?
Please note that the Updater connects to the specified URL and reads information, it does not connect to a server to write information in it.

In order to write the information you want to a text file you can follow the steps in the Write text into a file how-to. After this file is created, you need to copy it to your server through another custom action.

I'm afraid that we don't have an example for this custom action because it is very custom and complicated. This custom action would need to create a FTP connection to your server and send the file from the target machine. It should also handle the case in which the target machine doesn't have an Internet connection.

Another approach would be to somehow write text to an URL and a script on the server would interpret the text. However, this also exceeds my knowledge.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
craigi
Posts: 5
Joined: Thu Jun 05, 2008 8:09 am

Re: Custom action to capture textbox data and send to server?

All I need is an installation script that first registers a user then puts a file in the My Documents folder.
cosmin wrote:Another approach would be to somehow write text to an URL and a script on the server would interpret the text. However, this also exceeds my knowledge.
If I could get a sample MSI installer with name, company, and email address passed via a URL to a web form, I'd buy the software right now...

Craig
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom action to capture textbox data and send to server?

Hi Craig,

Here is a method which allows you to receive the username, company and email on your server (I attached a sample project):
- create and configure your Advanced Installer project
- go to the Custom Actions page and create a "New Attached Custom Action"
- select the "C:\Program Files\Caphyon\Advanced Installer 6.3.1\custact\serval.dll" file when prompted for the source of the custom action
- use the default options for this custom action
- go to the Dialogs page and create a custom dialog
- add three Edit box controsl which will retrieve the username, company and email of the user
- set the properties of these edit boxes to USERNAME and COMPANYNAME and PIDKEY
- select the "Next" button on your custom dialog
- make sure it has these Published control events (in this exact order):

Code: Select all

[PIDKEY]              1                                  AI_INSTALL AND NOT PIDKEY
[AI_SERVAL_TYPE]      3                                  AI_INSTALL
[AI_SERVAL_URL]       http://myserver.com/collect.php    AI_INSTALL
DoAction              serval.dll                         AI_INSTALL
NewDialog             FolderDlg                          AI_INSTALL
- note that you need to replace "http://myserver.com/collect.php" with an URL to the "collect.php" file on your server
- place the "collect.php" file on your server and make sure it has write access

Here is the content of the "collect.php" file:

Code: Select all

<?php

/**
 * Server response to client application.
 */
function ServerResponse($killScript = false)
{
  echo "601";
  if($killScript == true)
    die();
}

// test if there is any information to collect
if(!isset($_POST['username']) || trim($_POST['username']) == '')
  ServerResponse(true);

$serverAppDir = dirname(__FILE__) . '/';
$installLog   = $serverAppDir . 'installs/users.log';

// create directory, if not present
mkdir(dirname($installLog));

// open file in "append" mode (create if not exists)
if(!$handle = fopen($installLog, 'a')) 
{
  //echo "Cannot open file ($installLog)";
  ServerResponse(true);
}

// create install information record
$content = "USERNAME=[" . trim($_POST['username']) . "], COMPANYNAME=[" . trim($_POST['company']) . "], EMAIL=[" .  trim($_POST['sn'])  . "]\n";

// log collected information
if(!fwrite($handle, $content))
{
  //echo "Cannot write to file ($installLog)";
}

// close file handle
fclose($handle);

// send response acknolegement to client
ServerResponse();

?>
Let me know if you encounter any problems with this approach. Note that if the PHP file cannot be found, the installation will give an "Invalid Serial Number" message.

This is a temporary solution for what you need to do. In a future version of Advanced Installer we will include a feature which will allow the package to send information to a server.

Regards,
Cosmin
Attachments
SendToServer example.zip
(2.39 KiB) Downloaded 288 times
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
craigi
Posts: 5
Joined: Thu Jun 05, 2008 8:09 am

Re: Custom action to capture textbox data and send to server?

cosmin wrote:Here is a method which allows you to receive the username and company on your server (I attached a sample project):
Outstanding!

I'll check it out. :-)

Craig
craigi
Posts: 5
Joined: Thu Jun 05, 2008 8:09 am

Re: Custom action to capture textbox data and send to server?

Hi Cosmin -

So -- I was able to get everything working except one thing: I also need to log the email address. I added a field for the email address on the dialog and in the PHP script, but no luck.

Is that something supported by that dll? If so, what's the name of the variable?

In case you couldn't tell, I am not a programmer. (LOL) I'm just trying to hack my way to a solution.

Finally -- assuming I finally get this working (of which I'm REALLY hopeful!), does this require the Professional license or the Enterprise license? Everything else I need to accomplish is in the basic version.

Thanks again for all your help!

Craig
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom action to capture textbox data and send to server?

Hi Craig,
I also need to log the email address.
I modified the original post to also include the email. Note that I used a hack because the custom action doesn't support sending the email address (I used a variable for the serial number to store the address).
does this require the Professional license or the Enterprise license?
What you need to do requires an Enterprise license because you need to use a custom dialog.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
craigi
Posts: 5
Joined: Thu Jun 05, 2008 8:09 am

Re: Custom action to capture textbox data and send to server?

Very creative -- I should have thought of that!

Thank you again.

Craig
craigi
Posts: 5
Joined: Thu Jun 05, 2008 8:09 am

Re: Custom action to capture textbox data and send to server?

Hi Cosmin -

OK -- so it wasn't what I was thinking -- but it works. : )

Are there really only 3 fields available: USERNAME, COMPANYNAME, and PIDKEY?

No way to also pass arguments through the launched URL?

For example:

www. company.com/collect_reg.php?field4="[FIELD4]"&field5="[FIELD5]"

Thanks again!

Craig
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom action to capture textbox data and send to server?

Hi Craig,
Are there really only 3 fields available: USERNAME, COMPANYNAME, and PIDKEY?
The properties used by the custom action I mentioned are: PIDKEY, USERNAME, COMPANYNAME and ProductVersion. Since ProductVersion is set automatically from the project, only the other three properties can be used. Note that this custom action was not designed for sending information to a server, it was designed for verifying a serial number. However, a future version of Advanced Installer will include a custom action which allows you to send the information you want.
No way to also pass arguments through the launched URL?
Since the information is posted programmatically by the custom action, the URL cannot receive arguments.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”