我需要使用组策略将两行添加到文本文件。 我不能用更新的文件replace文件,因为文件的内容因机器不同而不同,但是所有的文件都必须用两行更新。 有没有可能做到这一点?
我已经知道如何使用VBScriptreplace文件,然后通过组策略应用它。
谢谢,阿卜杜拉
这个VBScript让你知道它应该是什么样子。 他们的关键是打开文件进行追加,而不是写作。 这将只在文本文件的底部添加两行,而不pipe其内容。
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
你也可以使用batch file来做到这一点。 echo "Add this line to the end of the file." >> \\path\to\file.txt echo "Add this line to the end of the file." >> \\path\to\file.txt或其他。 只是不要使用单一的redirect操作>而不是> ,否则你会后悔的。