Dbyte
Technical User
- Mar 6, 2002
- 87
I am trying to copy a single file to multiple PCs (using a text file to generate the array of workstation names) then verify the file was copied. For testing purposes the text file currently has only 2 PCs listed in it, 1 is Win2K & the other is XP. Here's my code:
2 strange things are happening:
1. The file is only being copied to the C: drive on the XP machine.
2. Both machines are generating a Success response to the FileExists statement only if the file is on the C: drive of the machine I'm actually running the script from. This machine is not listed in the text file.
The results above occur whether I am logged onto a PC or on the PDC. In both cases I log on w/ the domain admin's credentials (again, for testing). We are using Active Directory 2K.
Any suggestions on what is missing here?
BTW, big thanks to markdmac for his FAQs, which helped me get this far.
Code:
Option Explicit
'Declare variables
Dim oFSO, oTextStream, RemotePC, sComputer
Set oFSO = CreateObject("Scripting.FileSystemObject")
'open data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close data file
oTextStream.Close
'Copy & verify file
For Each sComputer In RemotePC
oFSO.CopyFile "\\server\share\file", "c:\file", True
If oFSO.FileExists("c:\file") Then
Wscript.Echo "Success " & sComputer
Else
Wscript.Echo "FAILED " & sComputer
End If
Next
'Clean up & quit
Set oFSO = Nothing
Set oTextStream = Nothing
Wscript.Quit
2 strange things are happening:
1. The file is only being copied to the C: drive on the XP machine.
2. Both machines are generating a Success response to the FileExists statement only if the file is on the C: drive of the machine I'm actually running the script from. This machine is not listed in the text file.
The results above occur whether I am logged onto a PC or on the PDC. In both cases I log on w/ the domain admin's credentials (again, for testing). We are using Active Directory 2K.
Any suggestions on what is missing here?
BTW, big thanks to markdmac for his FAQs, which helped me get this far.