-
Overwrite file on mass.
How would i go about overwriting a file on all the machines on our RM network easily.
There's a txt.ini file we have in c:/windows/sytem32 folder to help a program run, however we have changed some values in it.
Ad i certainly don't want to manually go round overwriting the file on a few hundred machines.
-
I would use a startup script. This VBS code will check a master copy of the .txt file on the server against the local one. If the one on the server is more upto date it will update the client one.
Code:
Set objFSO = CreateObject ("Scripting.FileSystemObject")
on error resume next
sourcefile1 = "c:\file.txt"
sourcefile2 = "\\server\NETLOGON\bin\files.txt"
Set objFile = objFSO.GetFile(sourcefile1)
strFile1 = objFile.DateLastModified
Set objFile = objFSO.GetFile(sourcefile2)
strFile2 = objFile.DateLastModified
If strFile1 <> strFile2 Then
objFSO.CopyFile "\\server\NETLOGON\bin\file.txt", "C:\"
End IF
wscript.quit
The good thing about server 2008 with this type of thing you don't have to mess around with scripts.
edit: you will need to put some variables in there as well, i will see what i can find.
-
and use that as a start up script... is there a basic guide how to do this? as im pretty new to this.
-
Hi there
If you copy and paste this code into a notepad and change the path of the original file on the server and the destination. Once you have done that save the file in your netlogon file but save it as a VBS file. for example copyfile.vbs
After that add the script to start-up scripts in group policy.
Code:
Set objFSO = CreateObject ("Scripting.FileSystemObject")
on error resume next
sourcefile1 = "c:\file.txt"
sourcefile2 = "\\server\NETLOGON\bin\file.txt"
Set objFile = objFSO.GetFile(sourcefile1)
strFile1 = objFile.DateLastModified
Set objFile = objFSO.GetFile(sourcefile2)
strFile2 = objFile.DateLastModified
If strFile1 <> strFile2 Then
objFSO.CopyFile "\\server\NETLOGON\bin\file.txt", "C:\"
End IF
wscript.quit
Let me know how you get on.
-
Alternatively you could use xcopy:
Code:
@echo off
xcopy "\\servername\sharename\txt.ini c:\windows\system32\" /y
Again put this in a startup script.
-
i get an invalid charcater line 1 char 1, after running the xcopy.
no errors on the other but it just didnt copy the file across.
-
If you're on CC3, you could use a package to deploy the file, which may be a bit overkill it certainly allows you version control should you make changes later.
-
can we see a copy of your VBS script please?
for xcopy you may have to put quotations around the path if there is a space in the location.
-
Sorry my bad, it should be:
Code:
@echo off
xcopy "\\servername\sharename\txt.ini" "c:\windows\system32\" /y