简体   繁体   English

批处理文件执行后关闭命令提示符窗口

[英]Close command prompt window after batch file execution

How to automatically close command prompt window after batch file execution.如何在批处理文件执行后自动关闭命令提示符窗口。

I tried command Start "" & Exit 0 but it's not working.我试过命令Start "" & Exit 0但它不起作用。

Start ""
@ECHO OFF
C:
cd c:\wamp\www\phpfile
php genCSV.php
"c:\program files\coreftp\coreftp.exe" -s-O -site UPLH -u D:\Files\out\*.*   -p /Import/
del /Q c:\wamp\www\txt\*.*

Solution解决方案

I used "exit /B" at the of script as per Joey's below answer.根据乔伊的以下答案,我在脚本中使用了“exit / B”。

If you really want to close even an interactive session, then just use exit .如果你真的想关闭一个交互式会话,那么只需使用exit Generally though, eg from Explorer, batch files are started with cmd /c which will close the console after the batch file completes.通常,例如从资源管理器中,批处理文件以cmd /c启动,这将在批处理文件完成后关闭控制台。

Make sure no text is displayed in the console window to make it close automatically at the end of the batch file.确保控制台窗口中没有显示任何文本,以使其在批处理文件末尾自动关闭。 Use the EXIT command with the /B which ends the batch file right then the exit returns to the command window.使用 EXIT 命令和 /B 结束批处理文件,然后退出返回到命令窗口。 The clear console will close on certain systems.清除控制台将在某些系统上关闭。 See http://www.robvanderwoude.com/exit.phphttp://www.robvanderwoude.com/exit.php

You could place this in your Batch file (notice the squiggly after the t in Exit - you most likely will need to use that - but you can try with out it.你可以把它放在你的批处理文件中(注意 Exit 中 t 后面的波浪线 - 你很可能需要使用它 - 但你可以尝试不使用它。

Set WshShell = CreateObject("WScript.Shell") 
WshShell.SendKeys "Exit~"
WshShell.SendKeys "{ENTER}"

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

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