启动.exe文件后关闭批处理

时间:2016-10-12 19:08:06

标签: windows batch-file cmd

所以我在运行文件后关闭CMD时遇到问题! 在下面的代码中,您可以看到我正在使用EXIT命令,但在按Enter后,驱动器名称显示出来,这种情况一次又一次地发生 我已经尝试过没有停顿,它不会工作(我希望它暂停在那里) 所以我希望它在用户按下Enter后退出CMD。

我给它一个错误的.net框架号来测试它是否会运行exe文件,它运行它但之后不会关闭(cmd不会关闭我的意思)

我看过这些问题:

Close a batch file after running the jar file

close windows command prompt after all process completed in the batch file

cmd.exe doesn't close after starting exe

这是我遇到的问题:运行批处理文件的图片,您可以在下面的链接中看到!

How the CMD looks when I run the batch file

提前致谢!

@echo off

echo " _____________________________ "
echo "|                             |"
echo "|       softRAD Loader        |"
echo "|_____________________________|"

echo " _________________________________________________________________________ "
echo "|                                                                         |"
echo "|          Checking the .Net Framework Installed on Your System           |"
echo "|_________________________________________________________________________|"


REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v5.5" /v Version
IF %errorlevel%==0 GOTO INSTALL
IF %errorlevel%==1 GOTO UNINSTALL




:INSTALL

echo " __________________________________________________________ "
echo "|                                                          |"
echo "|  .Net Framework v3.5 found , Starting the softRAD.exe    |"
echo "|----------------------------------------------------------|"
echo "|             This window closes in 3 seconds              |"
echo "|__________________________________________________________|"

echo.
ping -n 2 127.0.0.1>nul
echo "   3   "
ping -n 2 127.0.0.1>nul
echo "   2   "
ping -n 2 127.0.0.1>nul
echo "   1   "
ping -n 2 127.0.0.1>nul

GOTO end

:UNINSTALL

echo " __________________________________________________________ "
echo "|                                                          |"
echo "|  .Net Framework Not found , Attempting to Install it.    |"
echo "|----------------------------------------------------------|"
echo "|          If this Doesnt Work , Please Install the        |"
echo "|      .net Framework Included on the DVD manually.        |"
echo "|__________________> 3.5 client profile <__________________|"

cmd /K "%~dp0dotnetfx35.exe"
pause
EXIT


:end

exit

2 个答案:

答案 0 :(得分:0)

输入start /?。批处理文件等待程序在继续之前退出,这与您键入时不同。开始修改启动程序的标准行为。最简单的是,

start "Title" Notepad 

同样timeout是暂停而非ping的方法。输入timeout /?

答案 1 :(得分:0)

/K中的cmd /K表示在命令完成后保持cmd窗口打开。

要在命令完成后关闭cmd窗口,请使用/C代替/K

来自cmd /?的输出:

  

CMD [/ A | / U] [/ Q] [/ D] [/ E:ON | / E:OFF] [/ F:ON | / F:OFF] [/ V:ON | / V:OFF]       [[/ S] [/ C | / K] string]

     

/ C执行string指定的命令,然后终止
  / K执行string指定的命令但仍然是