简体   繁体   English

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

[英]Closing a batch after starting an .exe file

So I'm having Problem with closing the CMD after it runs a file ! 所以我在运行文件后关闭CMD时遇到问题! in the code below as you can see I'm using an EXIT command but after pressing Enter the Drive name shows up and this happens again and again I have tried it without the pause to , it wont work ( I want it to pause there tho ) So i want it to exit the CMD after the user presses the Enter. 在下面的代码中,你可以看到我正在使用EXIT命令,但在按Enter后,驱动器名称出现,这种情况一次又一次地发生,我已经尝试了它没有暂停,它不会工作(我希望它暂停在那里)所以我希望它在用户按Enter后退出CMD。

I gave a wrong .net framework number to it to test if it will run the exe file or not , it runs it but it wont close afterwards ( the cmd wont close i mean ) 我给它一个错误的.net框架号来测试它是否会运行exe文件,它运行它但之后不会关闭(cmd不会关闭我的意思)

I have looked at these questions : 我看过这些问题:

Close a batch file after running the jar file 运行jar文件后关闭批处理文件

close windows command prompt after all process completed in the batch file 在批处理文件中完成所有进程后关闭Windows命令提示符

cmd.exe doesn't close after starting exe 启动exe后cmd.exe不会关闭

this is the problem Im having : Took a picture of the batch file when it runs which you can see on link below ! 这就是我遇到的问题:当它运行时拍下批处理文件的图片,你可以在下面的链接上看到!

How the CMD looks when I run the batch file 我运行批处理文件时CMD的外观

Thanks in advance ! 提前致谢 !

@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

Type start /? 输入start /? . Batch files wait for programs to exit before continuing unlike when you are typing. 批处理文件等待程序在继续之前退出,这与您键入时不同。 Start modifies the standard behaviour of starting programs. 开始修改启动程序的标准行为。 At it's most simple, 最简单的,

start "Title" Notepad 

Also timeout is the way to do a timeout not ping . timeout也是超时而非ping Type timeout /? 输入timeout /? .

The /K in cmd /K means that you keep the cmd window open after the command finishes. /K中的cmd /K表示在命令完成后保持cmd窗口打开。

To close the cmd window after the command finishes, use /C instead of /K . 要在命令完成后关闭cmd窗口,请使用/C而不是/K

From the output of cmd /? cmd /?的输出 :

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

/C Carries out the command specified by string and then terminates / C执行string指定的命令,然后终止
/K Carries out the command specified by string but remains / K执行string指定的命令但仍然存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM