0

I have a batch file that looks like this:

del db.log
start /b mongod --dbpath %~dp0 --logpath db.log

It should delete the existing log file, and then start mongodb without creating a new cmd, logging to db.log. The cmd window still shows though. What am I doing wrong?

1 Answers1

1

The three ways to start programs.

Specify a program name

c:\windows\notepad.exe

In a batch file the batch will wait for the program to exit. When typed the command prompt does not wait for graphical programs to exit.

If the program is a batch file control is transferred and the rest of the calling batch file is not executed.

Use Start command

start "" c:\windows\notepad.exe

Start starts a program and does not wait. Console programs start in a new window. Using the /b switch forces console programs into the same window, which negates the main purpose of Start.

Start uses the Windows graphical shell - same as typing in WinKey + R (Run dialog). Try

start shell:cache

Use Call command

Call is used to start batch files and wait for them to exit and continue the current batch file.

trigger
  • 89