kreya
kreya

Reputation: 1229

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.

Upvotes: 2

Views: 19125

Answers (2)

Joey
Joey

Reputation: 354794

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

Upvotes: 1

Ken
Ken

Reputation: 2838

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}"

Upvotes: 0

Related Questions