Jump to content
Sign in to follow this  

Script for copying files from all network PCs in host file.

Recommended Posts

I want to be able to copy text files from a closed network of PCs before the machines are migrated.

is it possible to read in a host file that has all the machines, then copy the file from each to a folder with the machine name?


Share this post

Link to post
Share on other sites

Yes, just compile your script and the run-as an administrator account that has admin privileges on each of the remote systems.  In your script just have the script read the host file into an array and then using that array just copy the files using the unc path \\$aComputers[$i]\c$\<Path to file>.

Hope that makes sense.

Share this post

Link to post
Share on other sites

Sure.  Start with FileReadToArray or _FileReadToArray (see the Help file for details), then loop through the array to run the copy operations on each machine.

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>


Func Example()
    ; Define a variable to pass to _FileReadToArray.
    Local $aArray = 0

    ; Read the current script file into an array using the variable defined previously.
    ; $iFlag is specified as 0 in which the array count will not be defined. Use UBound() to find the size of the array.
    If Not _FileReadToArray(@ScriptFullPath, $aArray, 0) Then
        MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.

    ; Display the array in _ArrayDisplay.
    ; Loop through the array and do your file copy operations
    For $i = 1 to Ubound($aArray) -1
         FileCopy(@TempDir & "\*.au3", @TempDir & "\Au3Files\", $FC_OVERWRITE + $FC_CREATEPATH)
EndFunc   ;==>Example


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...