No announcement yet.

TestConnection screen for Setup Factory

  • Filter
  • Time
  • Show
Clear All
new posts

  • TestConnection screen for Setup Factory

    If you need to check for an active and working internet connection, you would normally use the function HTTP.Connection() in your Lua script. This function, however, has a slight problem: it will block your installer until it times out or receives an answer from the remote server, not giving your customer any visual feedback about the remaining time if no connection can be established. You cannot start a timer with Screen.StartTimer() and control a progress bar, because the connection test will block the application, and the timer will not fire.

    If you need to overcome this limitation, you can use this custom screen instead. It will use a very small application (only 22 kB in size!) that performs the connection test for you instead of HTTP.TestConnection(), allowing you to give visual feedback to the user about the process. After you install this custom screen, just add it to your project, and study the provided code in Lua, changing it to fit your needs. The range of the progress bar is set to 40, and the timer will fire twice each second. A full bar represents the maximum wait time of 20 seconds.

    This solution has some limitations that may be important to you:
    • The timeout period is fixed at 20 seconds (the default value for Winsock operations);
    • The program will connect to the remote server at port 80 (the default port for web servers);
    • There is no support for proxies. This can be added later, should there be requests for this.

    Here is how the screen does look like with the default theme while the connection is being tested (of course you can change everything - after all, it is a custom screen):

    The executable to test the connection (TestConnection.exe) will be deployed into the Includes sub folder of your Setup Factory installation. Don't forget to add this program as a primer file in your project.

    You find the installer here.


  • #2
    I want to test connection then if connected display web site. Checked successful.

    res = File.Run(SessionVar.Expand("%TempLaunchFolder%\\TestConnection.exe"), "", "", SW_HIDE, true);
    	error = Application.GetLastError();
    	-- stop timer as soon as function returns
    -- now check the result
    	if (error == 0) then
    	if (res == 0) then
    		-- TestConnection was able to connect to URL
    		bConnected = true;
    		DlgScrollingText.SetProperties(CTRL_SCROLLTEXT_BODY_01, {Text = ""});
    		-- TestConnection timed out or failed
    		bConnected = false;
    		DlgScrollingText.SetProperties(CTRL_SCROLLTEXT_BODY_01, {Text = "Can't connect to server"});
    		-- jump to an error screen, if you need connectivity
    	bConnected = false;
    	DlgScrollingText.SetProperties(CTRL_SCROLLTEXT_BODY_01, {Text = "Can't connect to server"});
    	-- error while running TestConnection.exe (have you included the primer file?)
    	-- jump to appropriate screen
    But it display as text only. DlgScrollingText sets to HTML mode.


    • #3
      it's doing exactly what you're telling it to do.
      you'll want to save the webpage to disk; then load it into a variable, THEN set the Text=cMyHTMLPage


      • #4
        hum ok So I downloaded the install files... It puts a testconnexion.exe in /includes.. but then..?? where is the script to use that and the "custom screen"? because testconnexion.exe alone does nothing. so what should I do next to use this in my project? I put it in primer file section.. and then..? thank you.


        • #5
          You appear to have lost the part where you are supposed to add the new screen to your current project. The script is there, embedded in the custom screen.

          Last edited by Ulrich; 11-24-2010, 03:02 PM.