Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy & verify file existence on multiple remote PCs 1

Status
Not open for further replies.

Dbyte

Technical User
Mar 6, 2002
87
0
0
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:

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.
 
try somtheng like
Code:
For a = 0 to ubound(RemotePC )' sComputer In RemotePC
   oFSO.CopyFile "\\server\share\file", "\\" & RemotePC(a)& "\file", True
   If oFSO.FileExists("\\" & RemotePC(a)& "\file", ) Then
      Wscript.Echo "Success " & sComputer
   Else
      Wscript.Echo "FAILED " & sComputer
   End If
Next
 
Am now getting a "Path Not Found" error on this line:
[blue]oFSO.CopyFile "\\server\share\file", "\\" & RemotePC(a) & "\file", True[/blue]

I confirmed the file's presence in the correct folder on the file server & that the folder is shared to Everyone. I was also able to ping the destination workstations by hostname from the workstation I'm running the script on. I also navigated to the file's location on the file server from both workstations in the text file. Lastly, I updated the text file to use the workstation's IP addresses instead of hostnames - same error message as above.

Any other thoughts/ideas?
 
\\" & RemotePC(a) & "\file"

what does this actually look like???

i presume it is something like \\USA034566W\C$\update.ini??

can you, from the machien that is running the script manually copy the file from the server to the location on the target machine (permissions etc)
 
Most of that code all looks familiar. :)

Code:
For Each sComputer In RemotePC
   oFSO.CopyFile "\\server\share\filename", "\\" & sComputer & "\C$\filename", True
   If oFSO.FileExists("\\" & sComputer & "\C$\filename") Then
      Wscript.Echo "Success " & sComputer
   Else
      Wscript.Echo "FAILED " & sComputer
   End If
Next

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Once again Markdmac you come up w/ a solution. At least this time I was close to getting it though! ;-)

Big thanks & a star for you sir.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top