‘------------- Script Starts from here --------------------
Const ForReading = 1
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Computers.txt")
Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = "\\" & strComputer & "\C$\Scripts\Test.doc"
objFSO.CopyFile "C:\Scripts\Test.doc", strRemoteFile, OverwriteExisting
Loop
’ ---------------------Script Ends here ----------------------------------
Here, at long last, we call the CopyFile method, passing three parameters:
- The path to the local file (C:\Scripts\Test.doc), the file we want copied.
- The UNC path for the remote computer (stashed in the variable strRemoteFile).
- The constant OverWriteExisting (just in case Test.doc already exists in the C:\Scripts folder).
We copy the file, then loop around and repeat the process with the next computer in the list.


No comments:
Post a Comment