이 스크립트가 두 개 값을 하나가 아닌 동일한 텍스트 파일로 대체하려고합니다. 그러나 12 행의 주석 처리를 제거하면 스크립트가 중단됩니다. 이것을 루프로 만들어야합니까, 아니면 여러 번 대체 할 수 있습니까? 첫 번째 교체vbscript 대체 텍스트 - 하나가 두 개 모두 작동합니다.
strNewText = Replace(strText, "***COMPNAME***", strCompname)
strNewText = Replace(strNewText , "***Winkey***", strPoductkey)
그렇지 않으면 당신은 잃게됩니다, 단지 두 번째가 나타납니다 :
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
당신은 각 교체품을 인쇄하고 싶다고 분명히 밝혀야합니다. 그렇지 않으면 Frederik의 코드가 동시에 교체 한 다음 인쇄하려는 경우에 효과적입니다. – Malachi