我只想在完成如下批处理文件后打开cmd.exe窗口。我正在测试从Windows 7资源管理器启动它,cmd.exe版本6.1.7601。哔哔声和暂停工作正常,但我想让cmd保持打开以发出后续命令。
@echo off
:: wschloss Jul 2015
:: This batch runs if the laptop's Core Temp is close to critical
:: as determined by the "Core Temp" utility at
:: "C:\ORION\System Information\CoreTemp\64bit\Core Temp.exe"
:: http://www.alcpu.com/CoreTemp/
::
color 1F :: White on Blue
:: Beeps!
echo .
type c:\bill\beep.txt :: causes the Laptop to beep for attention
cls
::
echo .
echo Laptop Critical Temperature Approaches!
echo .
echo Save Your Data and Cool me down NOW!
echo .
pause
color
exit /B
:: EOP
这似乎微不足道,但我显然遗漏了一些东西。谢谢你的帮助。
答案 0 :(得分:1)
将cmd /k
添加到文件末尾,以将程序重定向到命令提示符。 (它将结束您的程序,然后,在同一窗口中,打开命令提示符)
@echo off
:: wschloss Jul 2015
:: This batch runs if the laptop's Core Temp is close to critical
:: as determined by the "Core Temp" utility at
:: "C:\ORION\System Information\CoreTemp\64bit\Core Temp.exe"
:: http://www.alcpu.com/CoreTemp/
::
color 1F :: White on Blue
:: Beeps!
echo .
type c:\bill\beep.txt :: causes the Laptop to beep for attention
cls
::
echo .
echo Laptop Critical Temperature Approaches!
echo .
echo Save Your Data and Cool me down NOW!
echo .
pause
color
cmd /k
:: EOP
那,如果您希望清除之前的输出,您当然可以在cls
之前添加cmd /k
。
答案 1 :(得分:0)
使用cmd /k yourbatchfile.bat
命令行,然后exit /b
将按您的意愿运行。
答案 2 :(得分:0)
通常我先打开一个命令窗口,然后从那里运行我的批处理脚本,这样当脚本结束时我的窗口就不会关闭。
如果我希望能够双击脚本并让它运行并且窗口保持打开状态,那么我创建一个运行cmd /k "myscript.bat"
的快捷方式。
但听起来你不想做上述任何一种情况。您可以使用START / B在同一窗口中使用/ K选项启动新的CMD shell。您的父CMD shell将在脚本完成时终止,但子CMD shell将保留,因此窗口将保持打开状态。
@echo off
:: wschloss Jul 2015
:: This batch runs if the laptop's Core Temp is close to critical
:: as determined by the "Core Temp" utility at
:: "C:\ORION\System Information\CoreTemp\64bit\Core Temp.exe"
:: http://www.alcpu.com/CoreTemp/
::
color 1F :: White on Blue
:: Beeps!
echo .
type c:\bill\beep.txt :: causes the Laptop to beep for attention
cls
::
echo .
echo Laptop Critical Temperature Approaches!
echo .
echo Save Your Data and Cool me down NOW!
echo .
pause
color
start /b cmd /k
exit /B
:: EOP