Jump to content
Sign in to follow this  
AHRIMANSEFID

{Req} Download a file 3 server?

Recommended Posts

AHRIMANSEFID

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

Share this post


Link to post
Share on other sites
water

And the question is?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
AHRIMANSEFID

Run Code Send Error.

plz test code me.

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
AHRIMANSEFID

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

Share this post


Link to post
Share on other sites
AHRIMANSEFID

me add error to in link but not go in next link or next link.

me need help in server 1 error go to next server connect.

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
AHRIMANSEFID

Fix Line.

But New not Go Next step (Server 2) And (Server3).

Plz Help Me.

Thanks A lot.

:thumbsup:

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
AHRIMANSEFID

I want my code doing this: when it downloaded files form one server successfully don't switching to next server and starting the download again and if it was not successful obviously it must switch to next server.

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.