Can vbs generate bat file with line from InputBox?
Can anyone help me? This vbs script creates run.bat, but I need in run.bat the second line Answer from InputBox at the beginning of the vbs script. Is it 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
+3
source to share
1 answer
Of course, you just need to remove the double quotes from this string:
outFile.WriteLine """Answer"
so the value of the variable is Answer
written to the file instead of the string "Answer
:
outFile.WriteLine Answer
You can even make the answer on the same line as the text Your answer is:
if you create the output like this:
outFile.Write "Your answer is: " outFile.WriteLine Answer
or like this:
outFile.WriteLine "Your answer is: " & Answer
+4
source to share