mrlarue77 Posted July 25, 2019 Share Posted July 25, 2019 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? Link to comment Share on other sites More sharing options...
Subz Posted July 25, 2019 Share Posted July 25, 2019 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. Link to comment Share on other sites More sharing options...
TheyCallMeBacon Posted July 25, 2019 Share Posted July 25, 2019 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> Example() 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. EndIf ; Display the array in _ArrayDisplay. _ArrayDisplay($aArray) ; 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) Next EndFunc ;==>Example mrlarue77 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now