Adding lines to text files through Group Policy

I need to add two lines to text files using group policy. I cannot replace the files with the updated one since the content of the files differs from one machine to another, but all of them have to be updated with the two new lines. Is it possible to do that?

I already know how to replace a file using a VBScript, then applying it through group policy.

Thanks, Abdullah

-

This vbscript gives you an idea of what it should look like. They key is to open the files for appending, not for writing. This will just add two lines to the bottom of the text files regardless of their content.

Const ForAppending = 8

strFile1 = "c:\Temp\file1.txt"
strFile2 = "c:\Temp\file2.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFile1, ForAppending)

objFile.WriteLine "New Text to add 1"
objFile.WriteLine "New Text to add 2"

objFile.Close

Set objFile = objFSO.OpenTextFile(strFile2, ForAppending)

objFile.WriteLine "New Text to add 1"
objFile.WriteLine "New Text to add 2"

objFile.Close

-

You can also just use batch files to do it as well. echo "Add this line to the end of the file." >> \\path\to\file.txt or whatever. Just do not use the single redirection operation > instead of >, or you will be sorry.

-
That is to say the redirect operator > opens for write (clobber) as opposed to >> which opens for append. – jscott Jul 21 '10 at 18:27