vbs可以用InputBox中的行创建bat文件吗?

时间:2015-05-25 12:56:46

标签: batch-file vbscript inputbox

有人能帮帮我吗?这个vbs脚本创建了一个run.bat,但我需要在run.bat第二行中从VSP脚本开始的InputBox回答。有可能吗?

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 个答案:

答案 0 :(得分:4)

当然,您只需要删除此行中的双引号:

outFile.WriteLine """Answer"

以便将变量Answer的值写入文件而不是字符串"Answer

outFile.WriteLine Answer

如果您生成如下输出,您甚至可以使答案显示在与文本Your answer is:相同的行中:

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

或者像这样:

outFile.WriteLine "Your answer is: " & Answer