'Before using this, please update at LEAST the first two lines, and review the others to see what tokens you can use. 'Provide the source and destination files for token replacement. 'If they are the same, the tokens will be replaced and the file will be overwritten Const Source = "D:\Windows\Panther\unattend.xml" Const Destination = "D:\Windows\Panther\unattend.xml" 'Provide a list of token names and values to replace Dim tokens Set tokens = New TokenList tokens.AddToken "SERIALNUM", "%SERIALNUM%" 'Main program 'Constants that do not change Const ForReading = 1 Const ForWriting = 2 'Declare Variables for use in token replacement. Dim fileSource, fileDestination, objFSO, strContent 'Create a file system object Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") 'Open the source file and read it's content Set fileSource = objFSO.OpenTextFile(Source, ForReading, False) strContent = fileSource.ReadAll() fileSource.Close 'str replacement 'read thru each entry in the array and substitute in the tokenized file For i = 0 To tokens.Size strContent = Replace(strContent, "%" & tokens.Name(i) & "%" , tokens.Value(i)) Next 'Open Destination file and write updated content to it Set fileDestination = objFSO.OpenTextFile(Destination, ForWriting, True) fileDestination.Write(strContent) fileDestination.Close 'TokenList Class Const ARRAY_INCREMENT_SIZE = 10 Class TokenList Public aData Public iCount Public iSize Private Sub Class_Initialize() iCount = 0 iSize = ARRAY_INCREMENT_SIZE ReDim aData(1, iSize) End Sub Public Function AddToken(Name, Value) If iCount > iSize Then iSize = iSize + ARRAY_INCREMENT_SIZE ReDim Preserve aData(1, iSize) End If aData(0, iCount) = Name aData(1, iCount) = Value iCount = iCount + 1 End Function Public Property Get Name(iPos) If iPos < 0 OR iPos >= iCount Then Exit Property 'Invalid range Name = aData(0, iPos) End Property Public Property Get Value(iPos) If iPos < 0 OR iPos >= iCount Then Exit Property 'Invalid range Value = aData(1, iPos) End Property Public Property Get Size() Size = iCount End Property End Class