Jump to content

start 20 active downloads in one time after finish 1/20 start next download


harvester2001
 Share

Recommended Posts

Hi I need your help :)

I need download backup from 200 remote pc. I calculate that I can download 20 backups in one time. I need to create loop, take localizations from txt file and start 20 downloads in one time (i want use ShellExecute and robocopy), after finish one from running 20 take another localizations from txt file until localizations finish. And I need trigger if is 7:00 pause script. I hope you know what I mean :)

Many thanks for help, sorry for my english.

This is what I got:

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>

Local $targets = @ScriptDir& "\targets.txt"
Local $log_name = "\autoit.log"

MsgBox($MB_SYSTEMMODAL, "", "start copy", 1)


Example()

Func Example()

   If Not FileExists($targets) Then
      MsgBox($MB_SYSTEMMODAL, "", "The file targets.txt - doesn't exist!")
      Exit
   EndIf

   FileOpen($targets, 0)
   Global $arr[1000]
   ReDim $arr[_FileCountLines($targets)+1]

   For $i = 1 to _FileCountLines($targets)
       $line = FileReadLine($targets, $i)
       $arr[$i] = $line

      ; Check if is online
      Local $iPing = Ping($arr[$i], 250)
      If $iPing Then
         ; ONLINE
         $rc = FileCopy("\\"&$arr[$i]&"\e$\backup\", @ScriptDir&"\downloads\"&$arr[$i]&"\", $FC_CREATEPATH)

         If $rc = 0 Then
            _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" ONLINE error")
         Else
            _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" ONLINE done")
         EndIf
      Else
         ;OFFLINE
        _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" OFFLINE")
      EndIf
   Next


EndFunc   ;==>Example

MsgBox($MB_SYSTEMMODAL, "", "Finish downloads backups")
Exit

 

Edited by harvester2001
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

×
×
  • Create New...