3

can someone help me? This vbs script create a run.bat but I need in run.bat second line Answer from InputBox on start of vbs script. It is possible?

Answer = LCase(InputBox("Your Answer:", ""))
     If Len(Answer) Then
     Dim objFSO, outFile
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set outFile = objFSO.CreateTextFile("run.bat", True)
    outFile.WriteLine "Your answer is: "
    outFile.WriteLine """Answer"

    outFile.Close

    WScript.Echo "Done."
End If

1 Answers1

4

Sure, you just need to remove the double quotes from this line:

outFile.WriteLine """Answer"

so that the value of the variable Answer is written to the file instead of the string "Answer:

outFile.WriteLine Answer

You can even make the answer appear on the same line as the text Your answer is: if you generate the output like this:

outFile.Write "Your answer is: "
outFile.WriteLine Answer

or like this:

outFile.WriteLine "Your answer is: " & Answer
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328