Index: build_tools/sasview_deploy_test.au3
===================================================================
--- build_tools/sasview_deploy_test.au3	(revision 6bb4edd03c25040b4a24d32551f5c6be52083ca4)
+++ build_tools/sasview_deploy_test.au3	(revision 1cecc91f2645c816a42a491c2a34cd78e51ddfc8)
@@ -6,11 +6,13 @@
 ;
 ; 0 - OK
-; 1 - Installer failure
-; 2 - Problems running SasView (simple fitting)
-; 3 - Uninstaller failure
+; 1 - Download failure
+; 2 - Installer failure
+; 3 - Problems running SasView (simple fitting)
+; 4 - Uninstaller failure
 
 #include <Constants.au3>
 #include <FileConstants.au3>
 #include <MsgBoxConstants.au3>
+#include <InetConstants.au3>
 #include <WinAPIFiles.au3>
 
@@ -19,5 +21,14 @@
 
 ; Modifiable globals
-Global $fInstallerLocation = "C:\util\setupSasView.exe"
+if $CmdLine[0] == 0 Then
+   ; Expected command line with the build number as argument
+   Exit (-1)
+EndIf
+
+Local $lBuildNumber = $CmdLine[1]
+;Global $fInstallerLocation = "C:\util\setupSasView.exe" ; debug and testing location
+Global $fInstallerLocation = @TempDir & "\setupSasView.exe"
+Global $fRemoteInstallerLocation = "https://jenkins.esss.dk/sasview/job/SasView_Win7_Test/" & $lBuildNumber & "/artifact/sasview/dist/setupSasView.exe"
+Global $fUninstallerLocation = "C:\Program Files (x86)\SasView\unins000.exe"
 Global $lTimeout = 10          ; 10 sec timeout for waiting on windows
 Global $lInstallTimeout = 120  ; 2 min timeout for the installation process
@@ -28,28 +39,44 @@
 
 ;; MAIN SCRIPT
+Download()
 Install()
 RunSasView()
 Uninstall()
+
 Exit(0)
 
 ;==============================================================
+Func Download()
+   ; Download the file in the background with the selected option of 'force a reload from the remote site.'
+   ConsoleWrite("Downloading...." & @CRLF)
+   Local $iFailFlag = 1
+   Local $hDownload = InetGet($fRemoteInstallerLocation, $fInstallerLocation, $INET_FORCERELOAD)
+
+    ; Close the handle returned by InetGet.
+    InetClose($hDownload)
+	Assert($hDownload, $iFailFlag)
+	ConsoleWrite("Installer downloaded successfully to " & $fInstallerLocation & @CRLF)
+
+EndFunc
+
 Func Install()
    ;;;;; APPLICATION INSTALLED ;;;;;;;
    Local $sSetupWindow = "Setup - SasView"
-
+   Local $iFailFlag = 2
    ; Run setup
    if FileExists($fInstallerLocation) Then
 	  $installerPID = Run($fInstallerLocation)
-	  Assert($installerPID, 1)
+	  Assert($installerPID, $iFailFlag)
 	  Sleep(1000)
    Else
 	  ;$Error = ObjEvent(AutoIt.Error, "Setup file does not exist","123")
-	  Exit(1)
+	  Exit($iFailFlag)
    EndIf
 
    ; License click through
+   WinActivate($sSetupWindow) ; <-- REQUIRED when connecting from another host
    Local $test = WinWaitActive($sSetupWindow, "License Agreement", $lTimeout)
    ;ConsoleWrite("license agreement: " & $test)
-   Assert($test, 1)
+   Assert($test, $iFailFlag)
    sleep(1000)
 
@@ -59,5 +86,5 @@
    Sleep(1000)
    $test = WinWaitActive($sSetupWindow, "Select Destination Location", $lTimeout)
-   Assert($test, 1)
+   Assert($test, $iFailFlag)
    Send("{ENTER}")
 
@@ -65,5 +92,5 @@
    Sleep(1000)
    $test = WinWaitActive($sSetupWindow, "Select Additional Tasks", $lTimeout)
-   Assert($test, 1)
+   Assert($test, $iFailFlag)
    Send("{ENTER}")
 
@@ -71,5 +98,5 @@
    Sleep(1000)
    $test = WinWaitActive($sSetupWindow, "Ready to Install", $lTimeout)
-   Assert($test, 1)
+   Assert($test, $iFailFlag)
    Send("{ENTER}")
 
@@ -77,5 +104,5 @@
    Sleep(5000)
    $test = WinWaitActive($sSetupWindow, "Completing the SasView Setup Wizard", $lInstallTimeout)
-   Assert($test, 1)
+   Assert($test, $iFailFlag)
    Send("{ENTER}")
    ;ConsoleWrite("Installed" & @CRLF)
@@ -88,9 +115,9 @@
    ; Start app - DEBUG ONLY
    ;;Run("C:\Program Files (x86)\SasView\SasView.exe")
-
+   Local $iFailFlag = 2
    ; Wait for the window
    Sleep(1000)
    Local $hWnd = WinWaitActive("SasView  - Fitting -", "", $lTimeout)
-   Assert($hWnd, 2)
+   Assert($hWnd, $iFailFlag)
 
    ;;;;; Load a File
@@ -98,5 +125,5 @@
    Send("!{f}{ENTER}")
    WinWaitActive("Choose a file", "", $lTimeout)
-   Assert($hWnd, 2)
+   Assert($hWnd, $iFailFlag)
    Sleep(200)
 
@@ -119,9 +146,9 @@
 
    Local $hEnd = WinWaitActive("Confirm Exit", "", $lTimeout)
-   Assert($hEnd, 2)
+   Assert($hEnd, $iFailFlag)
    ControlClick($hEnd, "", "[CLASS:Button; INSTANCE:1]")
 
    Local $sv_closed = WinWaitClose($hWnd, "", $lTimeout)
-   Assert($sv_closed, 2)
+   Assert($sv_closed, $iFailFlag)
 
 EndFunc
@@ -129,15 +156,17 @@
 Func Uninstall()
 ;;;;; UNINSTALL ;;;;;;;
-   $installerPID = Run("C:\Program Files (x86)\SasView\unins000.exe")
+   Local $iFailFlag = 3
+   $installerPID = Run($fUninstallerLocation)
+   Assert($installerPID, $iFailFlag)
 
    Local $sSetupWindow = "SasView Uninstall"
 
    Local $test = WinWaitActive($sSetupWindow, "", $lTimeout)
-   Assert($test, 3)
+   Assert($test, $iFailFlag)
    Send("{TAB}{ENTER}")
 
    WinActivate("SasView Uninstal")
    $test = WinWaitActive($sSetupWindow, "SasView was successfully removed", $lTimeout)
-   Assert($test, 3)
+   Assert($test, $iFailFlag)
    Send("{ENTER}")
 
