Sign in to follow this  
Followers 0

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

1 post in this topic

#1 ·  Posted (edited)

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)


Func Example()

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

   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")
            _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" ONLINE done")
        _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" OFFLINE")

EndFunc   ;==>Example

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


Edited by harvester2001

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  
Followers 0

  • Similar Content

    • harvester2001
      Refresh array after one loop
      By harvester2001
      I need some help.
      I try ping computers from targets.txt (I have computer name in lines) if they ping I want do something and after that remove pc name from targets.txt. It`s working but problem is when I put this inside loop, because I need run script until all computers will not be removed from the list (targets.txt). I don`t know how to "refresh" array
      Please help
      #include <File.au3> #include <Array.au3> #include <MsgBoxConstants.au3> Local $PC_list = "\targets.txt" Local $bTargets = FileReadToArray(@ScriptDir& $PC_list) Do _check_ping() ;count_lines Local $file_count_lines = _FileCountLines(@ScriptDir& $PC_list) $i = $file_count_lines ConsoleWrite("na liście "&$i & @CRLF) Until $i = 0 ; IF &i = 0 then show MsgBox MsgBox(1, "xXx", "Finish") ;PING Func _check_ping() For $sPC In $bTargets $var = Ping($sPC, 250) If $var Then ConsoleWrite($sPC &"online"& @CRLF) ;Do something ;Delete $sPC from targets.txt Local $_Array _FileReadToArray ( @ScriptDir& "\targets.txt", $_Array ) $_Array = _DeleteArrayElementWithStringInstr ( $_Array, $sPC ) _FileWriteFromArray ( @ScriptDir& "\targets.txt", $_Array, 1 ) Sleep(200) Else ConsoleWrite($sPC &"offline"& @CRLF) EndIf Next EndFunc ;DELETE LINE FROM TXT Func _DeleteArrayElementWithStringInstr ( $_Array, $_String ) Local $_Item For $_Element In $_Array If StringInStr ( $_Element, $_String ) <> 0 Then _ArrayDelete ( $_Array, $_Item ) Else $_Item+=1 EndIf Next Return ( $_Array ) EndFunc ;==> _DeleteArrayElementWithStringInstr ( )  
    • harvester2001
      Variable must be of type "Object" inside loop
      By harvester2001
      I need help, I found script to check computer model. I want use it in loop to chceck multiple pc`s (targets.txt with computer names).
      But when i try use inside loop i get error: Variable must be of type "Object" and I dont know how to fix this
      Plz help
      Local $targets = @ScriptDir& "\targets.txt" Local $log_name = "\scan.log" $msgBox = MsgBox(4, "Scan", "need tergets.txt") Example() Func Example() If $msgBox = 7 Then exit EndIf If Not FileExists($targets) Then MsgBox($MB_SYSTEMMODAL, "", "File: targets.txt - no 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 ; chceck if pc is online Local $iPing = Ping($arr[$i], 250) If $iPing Then ; ONLINE Local $strComputer = $arr[$i] $colItems = "" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _ "0x10" + "0x20") If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Vendor: " & $objItem.Vendor & @CRLF $Output = $Output & "SN: " & $objItem.IdentifyingNumber & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "UUID: " & $objItem.UUID & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystemProduct" ) Endif Else ;OFFLINE _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" OFFLINE") EndIf Next EndFunc  
    • mond1106
      help loop parameter
      By mond1106
      how do I break the loop if my program is stuck in it without exiting the whole program?
      i just want it to start from the beginning of the code here is my program
      While 1
      $picture = "target.png"
      $result = _ImageSearch($picture,1,$x1,$y1,0,0)
      If $result = 1 Then

         $picture2 = "status.png"
         $result2 = _ImageSearch($picture2,1,$x1,$y1,0,0)
      Until $result2 = 1
      as you see if my program doesnt detect  or see picture2 then the loop wont stop.

    • ssah8
      Display loop count
      By ssah8
      So im creating a bot that logs in on a website. The website got a dropdown menu, and I have to choose the right one to login (Student)
      #include <IE.au3>
      #inculude <Inet.au3>
      $oIE = _IECreate("")
      $Name = _IEGetObjByName($oIE, "ssusername")
      $Pass = _IEGetObjByName($oIE, "sspassword")
      $dropdown = _IEGetObjByName($oIE, "usertype")
      _IEPropertySet($Name, 'innerText', 'censored')
      _IEPropertySet($Pass, 'innerText', 'censored')
      _IEPropertySet($dropdown, 'innerText', 'Student') <------ How do I make the dropdown list select "Student"?
    • Szmycu
      Ending Loop When found Pixel Color
      By Szmycu
      Hello i Have HP Bar in my game and it has 170px of width and then im gonna find start of this by mouse pos then i got $hpStart[0] = 661  $hpStart[1] = 230 ,  $hpEnd[0] = 839
      And there is from $hpStart[0] = 661 the same color - 0xCB423B but depends of my points of hp for example on pixel  $hpStart[0] = 745 would be another color not  0xCB423B and then i will know my my character got 50% of health points.
      I encountered problem here - for loop still looping to 839 and not founding this change in color for example on pixel $hpStart[0] = 745
      I would know actual $i counter and $hpEnd[0] then only i can calculate current health percent value 
      Please help me how to achieve that! Thanks for any help
      Func MouseCord() $MousePos = MouseGetPos() global $hpStart = $MousePos global $hpEnd = $hpStart $hpEnd[0] = $hpEnd[0] + 170 For $i = $hpStart[0] To $hpEnd[0] ; Looping from 661 to 839 $pixel = PixelGetColor($i,$hpStart[1]) If $pixel <> 0xCB423B Then $hpNowPer = ( $hpEnd[0] - $i ) / 170 $hpPoOdjeciu = 1 - $hpNowPer $hpNowPercent = Round($hpPoOdjeciu,2) ExitLoop ; - that not working EndIf Next EndFunc