Batch file 从控制台显示弹出窗口
是否可以在批处理文件中显示弹出/警报 我一直在读关于vb脚本使用的书,但这是完全必要的吗Batch file 从控制台显示弹出窗口,batch-file,cmd,dos,Batch File,Cmd,Dos,是否可以在批处理文件中显示弹出/警报 我一直在读关于vb脚本使用的书,但这是完全必要的吗 或不需要VBScript。您可以使用除批处理之外的任何编程语言(Powershell/Jscript/任何.NET语言) 这一行VBS脚本将创建一个消息框 msgbox wscript.Arguments(0) 使用 "C:\Users\User\Desktop\MsgBox.vbs" "Hi there" batchfile.bat "Text", "Window Title" "Default te
或不需要VBScript。您可以使用除批处理之外的任何编程语言(Powershell/Jscript/任何.NET语言) 这一行VBS脚本将创建一个消息框
msgbox wscript.Arguments(0)
使用
"C:\Users\User\Desktop\MsgBox.vbs" "Hi there"
batchfile.bat "Text", "Window Title" "Default text"
输入框
将用户输入的内容放入变量%Filter\u InputBox%
键入设置f
查看结果
你需要把自己的路径放进去
使用
"C:\Users\User\Desktop\MsgBox.vbs" "Hi there"
batchfile.bat "Text", "Window Title" "Default text"
请记住,如果希望控件返回到另一个批处理,则必须调用批处理文件
call batchfile.bat "Text", "Window Title" "Default text"
VBS文件
VBScript不是必需的。您可以使用除批处理之外的任何编程语言(Powershell/Jscript/任何.NET语言) 这一行VBS脚本将创建一个消息框
msgbox wscript.Arguments(0)
使用
"C:\Users\User\Desktop\MsgBox.vbs" "Hi there"
batchfile.bat "Text", "Window Title" "Default text"
输入框
将用户输入的内容放入变量%Filter\u InputBox%
键入设置f
查看结果
你需要把自己的路径放进去
使用
"C:\Users\User\Desktop\MsgBox.vbs" "Hi there"
batchfile.bat "Text", "Window Title" "Default text"
请记住,如果希望控件返回到另一个批处理,则必须调用批处理文件
call batchfile.bat "Text", "Window Title" "Default text"
VBS文件
您可以使用批处理JScript混合脚本,最终它是一个.Batch文件;例如:
@if (@CodeSection == @Batch) @then
@echo off
CScript //nologo //E:JScript "%~F0" "Hi, there..."
goto :EOF
@end
WScript.CreateObject("WScript.Shell").Popup(WScript.Arguments(0));
@if (@CodeSection == @Batch) @then
@echo off
rem Define values for Popup buttons
set /A YesNoAndCancel=3, QuestionMark=32
set /A YesButton=6, NoButton=7, TimedOut=-1
rem Call Popup JScript method with a 7 second timeout.
set /A buttons=YesNoandCancel + QuestionMark
CScript //nologo //E:JScript "%~F0" "Do you feel alright?" "Answer please:" %buttons% 7
set btn=%errorlevel%
if %btn% equ %YesButton% (
echo Glad to hear you feel alright.
) else if %btn% equ %NoButton% (
echo Hope you're feeling better soon.
) else if %btn% equ %TimedOut% (
echo Is there anybody out there?
)
goto :EOF
@end
var arg = WScript.Arguments;
WScript.Quit(WScript.CreateObject("WScript.Shell").Popup(arg(1),arg(3),arg(0),arg(2)));
将以前的代码复制到扩展名为.bat的文件中并执行它。弹出窗口还可能包括选择按钮,结果可能来自批次代码。例如:
@if (@CodeSection == @Batch) @then
@echo off
CScript //nologo //E:JScript "%~F0" "Hi, there..."
goto :EOF
@end
WScript.CreateObject("WScript.Shell").Popup(WScript.Arguments(0));
@if (@CodeSection == @Batch) @then
@echo off
rem Define values for Popup buttons
set /A YesNoAndCancel=3, QuestionMark=32
set /A YesButton=6, NoButton=7, TimedOut=-1
rem Call Popup JScript method with a 7 second timeout.
set /A buttons=YesNoandCancel + QuestionMark
CScript //nologo //E:JScript "%~F0" "Do you feel alright?" "Answer please:" %buttons% 7
set btn=%errorlevel%
if %btn% equ %YesButton% (
echo Glad to hear you feel alright.
) else if %btn% equ %NoButton% (
echo Hope you're feeling better soon.
) else if %btn% equ %TimedOut% (
echo Is there anybody out there?
)
goto :EOF
@end
var arg = WScript.Arguments;
WScript.Quit(WScript.CreateObject("WScript.Shell").Popup(arg(1),arg(3),arg(0),arg(2)));
有关JScript弹出方法的更多详细信息,请参阅。您可以使用批处理JScript混合脚本,最终它是一个.Batch文件;例如:
@if (@CodeSection == @Batch) @then
@echo off
CScript //nologo //E:JScript "%~F0" "Hi, there..."
goto :EOF
@end
WScript.CreateObject("WScript.Shell").Popup(WScript.Arguments(0));
@if (@CodeSection == @Batch) @then
@echo off
rem Define values for Popup buttons
set /A YesNoAndCancel=3, QuestionMark=32
set /A YesButton=6, NoButton=7, TimedOut=-1
rem Call Popup JScript method with a 7 second timeout.
set /A buttons=YesNoandCancel + QuestionMark
CScript //nologo //E:JScript "%~F0" "Do you feel alright?" "Answer please:" %buttons% 7
set btn=%errorlevel%
if %btn% equ %YesButton% (
echo Glad to hear you feel alright.
) else if %btn% equ %NoButton% (
echo Hope you're feeling better soon.
) else if %btn% equ %TimedOut% (
echo Is there anybody out there?
)
goto :EOF
@end
var arg = WScript.Arguments;
WScript.Quit(WScript.CreateObject("WScript.Shell").Popup(arg(1),arg(3),arg(0),arg(2)));
将以前的代码复制到扩展名为.bat的文件中并执行它。弹出窗口还可能包括选择按钮,结果可能来自批次代码。例如:
@if (@CodeSection == @Batch) @then
@echo off
CScript //nologo //E:JScript "%~F0" "Hi, there..."
goto :EOF
@end
WScript.CreateObject("WScript.Shell").Popup(WScript.Arguments(0));
@if (@CodeSection == @Batch) @then
@echo off
rem Define values for Popup buttons
set /A YesNoAndCancel=3, QuestionMark=32
set /A YesButton=6, NoButton=7, TimedOut=-1
rem Call Popup JScript method with a 7 second timeout.
set /A buttons=YesNoandCancel + QuestionMark
CScript //nologo //E:JScript "%~F0" "Do you feel alright?" "Answer please:" %buttons% 7
set btn=%errorlevel%
if %btn% equ %YesButton% (
echo Glad to hear you feel alright.
) else if %btn% equ %NoButton% (
echo Hope you're feeling better soon.
) else if %btn% equ %TimedOut% (
echo Is there anybody out there?
)
goto :EOF
@end
var arg = WScript.Arguments;
WScript.Quit(WScript.CreateObject("WScript.Shell").Popup(arg(1),arg(3),arg(0),arg(2)));
有关JScript弹出式方法的更多详细信息,请参阅。您最终能决定哪种方法最适合您吗?我无法抗拒你频繁的变化<代码>;-)代码>。一般来说,我建议你至少等两天(周末再等两天)再选择最佳答案。然后,在你发布的时候,选择对解决问题最有帮助的答案,而不是任何其他可能同时出现的相关/类似/新问题…aacini抱歉,如果我真的打扰了你,两个答案都很好,帮助我发现了新事物,我决定在看到serenity的更新之前选择你的答案,该更新提供了更多信息,然后我选择了他的答案,不仅是因为这额外的努力,而且因为他是新用户,我认为新用户比你需要某种动机,但我喜欢这两个答案,我希望你能在我的未来帮助我问题你能最终决定哪一个是最适合你的答案吗?我无法抗拒你频繁的变化<代码>;-)代码>。一般来说,我建议你至少等两天(周末再等两天)再选择最佳答案。然后,在你发布的时候,选择对解决问题最有帮助的答案,而不是任何其他可能同时出现的相关/类似/新问题…aacini抱歉,如果我真的打扰了你,两个答案都很好,帮助我发现了新事物,我决定在看到serenity的更新之前选择你的答案,该更新提供了更多信息,然后我选择了他的答案,不仅是因为额外的努力,而且因为他是新用户,我认为新用户比你更需要某种动机,但我喜欢这两个答案,我希望你能在我未来的问题上帮助我