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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transfer Replace File to Multiple Machines

Status
Not open for further replies.

Junbron

Technical User
Mar 5, 2012
15
NZ
Hi ...
I have an updated file and i want to transfer that single file to multiple servers and will overwrite the oldfile...

Need a vbscript to do this..

And is possible to do this without using xcopy ?

THanks
 
You pretty much requested the same thing a day before this one. Have you not read the starters that have been provided on the previous post ? What is the code you have and where are you having problems ?
 
sorryy.. here we go

-===============
Const DestinationFile = "c:\destfolder\anyfile.txt"
Const SourceFile = "c:\sourcefolder\anyfile.txt"

Set fso = CreateObject("Scripting.FileSystemObject")
'Check to see if the file already exists in the destination folder
If fso.FileExists(DestinationFile) Then
'Check to see if the file is read-only
If Not fso.GetFile(DestinationFile).Attributes And 1 Then
'The file exists and is not read-only. Safe to replace the file.
fso.CopyFile SourceFile, "C:\destfolder\", True
Else
'The file exists and is read-only.
'Remove the read-only attribute
fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes - 1
'Replace the file
fso.CopyFile SourceFile, "C:\destfolder\", True
'Reapply the read-only attribute
fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes + 1
End If
Else
'The file does not exist in the destination folder. Safe to copy file to this folder.
fso.CopyFile SourceFile, "C:\destfolder\", True
End If
Set fso = Nothing
=====================

SOrt of like that but yeah... need a loop so i can just put the computer list, destination folder and the file destination (the file that i need to distribute)
 
I gave you a suggestion of how to do this in your last post. Did you try it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top