Close command prompt window from batch file

I was starting an email client after booting my system, however my email database resides in an encrypted file system. In order to ensure the database is available, I made a batch file stored in the encrypted file system, and ran that from task scheduler. However I was stuck with the batch file running a command prompt which wouldn’t close after starting the program. Chat GPT gave a solution in one go, as here 🙂

If you want your batch file to close after starting a program, you can use the start command with the /B switch. Here’s an example:

@echo off
start "" /B "C:\Program Files (x86)\eM Client\MailClient.exe"
exit

The start command launches the specified program and the /B switch runs the program in the same window without creating a new one. The exit command at the end of the batch file ensures that the batch file closes once the program is launched.

This way, the batch file will start the program and then exit without waiting for the program to finish.

Scroll to Top