Jump to content
EduGeek EdSec 2026 is on Tuesday in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

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.

Posted (edited)

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.

 

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.

Edited by FN-Greatermanchester
Posted

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.

 

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.

Posted

Alternatively you could use xcopy:

 

@echo off
xcopy "\\servername\sharename\txt.ini c:\windows\system32\" /y

 

Again put this in a startup script.

Posted
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.
Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...