Jump to content

{Req} Download a file 3 server?


Recommended Posts

plz help for fix code :

3 server file download.

#NoTrayIcon
#RequireAdmin
Server1() ; Download a file in the background.
Server2() ; Wait for the Download to complete.
Server3() ; Wait for the Download to complete.

Func Server1()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @SystemDir & "\text1.exe"

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://www.test1.com/text.exe", @SystemDir & "\text.exe", 1, 1)

    ; Wait for the Download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)
    Local $aData = InetGetInfo($hDownload) ; Get all information.

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, 0)
    Local $iFileSize = FileGetSize($sFilePath)


    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the total number of bytes read and the filesize.
  MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _
        "Size: " & $aData[1] & @CRLF & _
        "Complete?: " & $aData[2] & @CRLF & _
        "Successful?: " & $aData[3] & @CRLF & _
        "@error: " & $aData[4] & @CRLF & _
        "@extended: " & $aData[5] & @CRLF)

ShellExecute("regedit.exe", '/s "' & @SystemDir & '\text.exe"')
Sleep(250)
; Delete the file.
FileDelete(@SystemDir & "\text.exe")

 EndFunc   ;==>Server1

Func Server2()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @SystemDir & "\text.exe"

    ; Download the file by waiting for it to complete. The option of 'get the file from the local cache' has been selected.
    Local $iBytesSize = InetGet("http://www.test2.com/text.exe", @SystemDir & "\text.exe", 1)


    ; Retrieve the filesize.
    Local $iFileSize = FileGetSize($sFilePath)

    ; Display details about the total number of bytes read and the filesize.
  MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _"Size: " & $aData[1] & @CRLF & _"Complete?: " & $aData[2] & @CRLF & _"Successful?: " & $aData[3] & @CRLF & _"@error: " & $aData[4] & @CRLF & _        "@extended: " & $aData[5] & @CRLF)

ShellExecute("regedit.exe", '/s "' & @SystemDir & '\text.exe"')
Sleep(250)
; Delete the file.
FileDelete(@SystemDir & "\text.exe")
EndFunc   ;==>Server2

Func Server3()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @SystemDir & "\text.exe"

    ; Download the file by waiting for it to complete. The option of 'get the file from the local cache' has been selected.
    Local $iBytesSize = InetGet("http://www.test3.com/text.exe", @SystemDir & "\text.exe", 1)


    ; Retrieve the filesize.
    Local $iFileSize = FileGetSize($sFilePath)

    ; Display details about the total number of bytes read and the filesize.
   MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _
        "Size: " & $aData[1] & @CRLF & _
        "Complete?: " & $aData[2] & @CRLF & _
        "Successful?: " & $aData[3] & @CRLF & _
        "@error: " & $aData[4] & @CRLF & _
        "@extended: " & $aData[5] & @CRLF)

ShellExecute("regedit.exe", '/s "' & @SystemDir & '\text.exe"')
Sleep(250)
; Delete the file.
FileDelete(@SystemDir & "\text.exe")
EndFunc   ;==>Server3
Link to comment
Share on other sites

And the question is?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I'm not going to run a script on my system that modifies the registry!

Please tell us what doesn't work and we will try to help!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Posted Image

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_Icon=001.ico
#AutoIt3Wrapper_Compile_Both=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


Server1() ; Download a file in the background.
Server2() ; Wait for the Download to complete.
Server3() ; Wait for the Download to complete.

Func Server1()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @SystemDir & "\sr.reg"

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://www.test.com/test.reg", @SystemDir & "\test.reg", 1, 1)

    ; Wait for the Download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)

    Local $aData = InetGetInfo($hDownload) ; Get all information.

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, 0)
    Local $iFileSize = FileGetSize($sFilePath)


    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the total number of bytes read and the filesize.
  MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _
        "Size: " & $aData[1] & @CRLF & _
        "Complete?: " & $aData[2] & @CRLF & _
        "Successful?: " & $aData[3] & @CRLF & _
        "@error: " & $aData[4] & @CRLF & _
        "@extended: " & $aData[5] & @CRLF)

ShellExecute("regedit.exe", '/s "' & @SystemDir & '\test.reg"')
Sleep(250)
; Delete the file.
FileDelete(@SystemDir & "\test.reg")

 EndFunc   ;==>Server1

Func Server2()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @SystemDir & "\test.reg"

    ; Download the file by waiting for it to complete. The option of 'get the file from the local cache' has been selected.
    Local $hDownload = InetGet("http://www.test.com/test.reg", @SystemDir & "\test.reg", 1)

Local $aData = InetGetInfo($hDownload) ; Get all information.

    ; Retrieve the filesize.
    Local $iFileSize = FileGetSize($sFilePath)

    ; Display details about the total number of bytes read and the filesize.
   MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _
        "Size: " & $aData[1] & @CRLF & _
        "Complete?: " & $aData[2] & @CRLF & _
        "Successful?: " & $aData[3] & @CRLF & _
        "@error: " & $aData[4] & @CRLF & _
        "@extended: " & $aData[5] & @CRLF)

ShellExecute("regedit.exe", '/s "' & @SystemDir & '\test.reg"')
Sleep(250)
; Delete the file.
FileDelete(@SystemDir & "\test.reg")
EndFunc   ;==>Server2

Func Server3()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @SystemDir & "\sru.reg"

    ; Download the file by waiting for it to complete. The option of 'get the file from the local cache' has been selected.
    Local $hDownload = InetGet("http://www.test.com/test.reg", @SystemDir & "\test.reg", 1)

Local $aData = InetGetInfo($hDownload) ; Get all information.

    ; Retrieve the filesize.
    Local $iFileSize = FileGetSize($sFilePath)

    ; Display details about the total number of bytes read and the filesize.
   MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _
        "Size: " & $aData[1] & @CRLF & _
        "Complete?: " & $aData[2] & @CRLF & _
        "Successful?: " & $aData[3] & @CRLF & _
        "@error: " & $aData[4] & @CRLF & _
        "@extended: " & $aData[5] & @CRLF)

ShellExecute("regedit.exe", '/s "' & @SystemDir & '\test.reg"')
Sleep(250)
; Delete the file.
FileDelete(@SystemDir & "\test.reg")
EndFunc   ;==>Server3
Edited by AHRIMANSEFID
Link to comment
Share on other sites

The error message is quite clear: You used a variable as array in line 31.

The only array you use is $aData.

You need to add more error checking after each function call.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I'm sure function Server2 gets called. Do you check that INetGet runs successfully?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You need to return if the download was successfull or not. Then you can decide if you need to call Server2.

Something like this:

$iResult = Server1() ; Download a file in the background.
If $iResult = 0 Then
    $iResult = Server2() ; Wait for the Download to complete.
    If $iResult = 0 Then
        Server3() ; Wait for the Download to complete.
    EndIf
EndIf

Func Server1()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = @SystemDir & "\sr.reg"

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://www.test.com/test.reg", @SystemDir & "\test.reg", 1, 1)
    
    ; Wait for the Download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, 2)

    Local $aData = InetGetInfo($hDownload) ; Get all information.
    If $aData[3] = False Then Return 0 ; Error occurred
    
    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, 0)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the total number of bytes read and the filesize.
    MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _
            "Size: " & $aData[1] & @CRLF & _
            "Complete?: " & $aData[2] & @CRLF & _
            "Successful?: " & $aData[3] & @CRLF & _
            "@error: " & $aData[4] & @CRLF & _
            "@extended: " & $aData[5] & @CRLF)

    ShellExecute("regedit.exe", '/s "' & @SystemDir & '\test.reg"')
    Sleep(250)
    ; Delete the file.
    FileDelete(@SystemDir & "\test.reg")
    Return 1
    
EndFunc   ;==>Server1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

BTW: In Server1 you use sr.reg and test.reg for the same download?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...