简体   繁体   中英

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 ""
@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.

If you really want to close even an interactive session, then just use exit . Generally though, eg from Explorer, batch files are started with cmd /c which will close the console after the batch file completes.

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. The clear console will close on certain systems. See http://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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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