我希望此脚本替换同一文本文件中的两个值而不是一个.但是,如果我取消注释第12行,它会破坏脚本.我是否必须将其转换为循环,还是可以进行多次替换?
Sub ReplaceTxt()
'Writes values we got earlier to our unattend file '
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strSIFpath, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "***COMPNAME***", strCompname)
' strNewText = Replace(strText, "***Winkey***", strPoductkey) '
Set objFile = objFSO.OpenTextFile("C:\$WIN_NT$.~BT\winnt.sif", ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Sub
Run Code Online (Sandbox Code Playgroud) vbscript ×1