使用脚本编辑文本注册表...我正在尝试更改的部分位于“”内部,当我自己运行脚本时它会更改“”内部的文本但是当我将其添加到我的脚本的其余部分del del是整个reg ???
有没有办法添加“”来替换?
我想要取代的是......
Some text
some text
some more text
"Some text" "ENTER_USERNAME_HERE"
some text
some text
some text
"Some Text" "ENTER_PASSWORD_HERE"
etc
etc
在我的脚本顶部超过1300行的DIMS等要添加到...
Storenumber在开头的输入框中,同样是密码
Sub SUB_Password
If (fso.FileExists(" Some File ")) then
File = " Some File "
Set objOtF = fso.OpenTextFile(AutoLog, 1)
content = objOtF.ReadAll
objOtF.Close
name = "ENTER_USERNAME_HERE"
Set objOtF = fso.OpenTextFile(AutoLog, 2)
objOtF.Write Replace(content, name , StoreNumber)
objOtF.Close
AutoLog = " Some File "
Set objOtF = fso.OpenTextFile(AutoLog, 1)
content = objOtF.ReadAll
objOtF.Close
pass = "ENTER_PASSWORD_HERE"
Set objOtF = fso.OpenTextFile(AutoLog, 2)
objOtF.Write Replace(content, pass , Password)
objOtF.Close
MsgBox " Some File is Complete.", vbOKonly+vbInformation+vbSystemModal
set oFile = fso.OpenTextFile(DestDir & "Install "&MyDate& ".log", Appendtxt)
oFile.WriteLine "Some File Password has been updated to " & Password
oFile.WriteLine "Some File User Name has been updated to " & StoreNumber
oFile.Close
obj.Run """ Some File """
wscript.sleep 5000
obj.Run """ Some File """
Else
MsgBox "Some File does not exist!" , vbOKOnly+vbExclamation+vbSystemModal , "System File Missing"
set oFile = fso.OpenTextFile(DestDir & "Install "&MyDate& ".log", Appendtxt)
oFile.WriteLine "Some File does not exist"
oFile.Close
End If
End Sub
答案 0 :(得分:0)
尝试下一步:
' VB Script Document
' http://stackoverflow.com/questions/23286417/adding-inside-a-apend-to-to-script
option explicit
On Error GoTo 0
Dim strResult: strResult = Wscript.ScriptName
'next assignment substitutes the "... ReadAll ..." code snippet
strResult = strResult & vbNewLine & _
"some text" & vbNewLine & _
"some more text" & vbNewLine & _
"""Some text"" ""ENTER_USERNAME_HERE""" & vbNewLine & _
"some text" & vbNewLine & _
"""Some Text"" ""ENTER_PASSWORD_HERE""" & vbNewLine & _
"etc" & vbNewLine
Dim pass: pass = """ENTER_PASSWORD_HERE"""
Dim name: name = """ENTER_USERNAME_HERE"""
Dim StoreNumber: StoreNumber = "StoreNumber"
Dim Password: Password = "Password"
Wscript.Echo strResult & vbNewLine & _
Replace( Replace( strResult, name, StoreNumber), pass, Password)
Wscript.Quit