vbs 可以用 InputBox 中的行创建 bat 文件吗?
Can vbs create bat file with line from InputBox?
有人可以帮助我吗?这个 vbs 脚本创建一个 run.bat 但我需要在 run.bat 第二行在 vbs 脚本开始时从 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
当然可以,您只需要从此行中删除双引号:
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
有人可以帮助我吗?这个 vbs 脚本创建一个 run.bat 但我需要在 run.bat 第二行在 vbs 脚本开始时从 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
当然可以,您只需要从此行中删除双引号:
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