0

In an application folder, there are n number of files. The application exe name "ClearMongoDb.exe" take some parameter like dbname.

ex: clearMongoDb.exe -db "SynchoMeshDB"

I am stuck with below :

  • I want to execute the exe from a batch file with same parameters
  • the batch file will be placed in the same application folder.
  • user can copy the application folder to any location

If user double clicks on the .bat file the exe should start working. User should not be required to make any changes in .bat file

PW.
  • 3,727
  • 32
  • 35
AMIT SHELKE
  • 501
  • 3
  • 12
  • 34
  • If I'm understanding, your question is "How do I launch an EXE from a batch file, with the same parameters given to the batch file?" Is this correct? – Jonathon Reinhart Oct 24 '13 at 08:18
  • and what is the problem? The name of the database could be changed and you want to read it? – npocmaka Oct 24 '13 at 08:19

3 Answers3

1

If the batch file is in the same folder as the executable, then you can do like this:

clearMongoDb.exe -db "SynchoMeshDB"

Just add this line in your batch file. Now the refference is in the same folder as the executable, no matter where the ENTIRE folder is moved (or at least the executable and batch file).

update:

As foxidrive mentioned, in order to see the output, place a PAUSE command at the end. So, your batch file should be like this:

clearMongoDb.exe -db "SynchoMeshDB"
PAUSE
Radu Gheorghiu
  • 20,049
  • 16
  • 72
  • 107
  • When I execute the batch file, the console window just flashes and closed without completing the process. Whereas if I run the application exe it takes more than 15 sec to complete the process. – AMIT SHELKE Oct 24 '13 at 09:06
  • 1
    place a PAUSE command there and you will be able to read the output. – foxidrive Oct 24 '13 at 09:13
0

If you just want to pass all the parameters given to a batch file to an EXE called from that batch file, use %*.

foo.exe %*

How do I pass command line parameters to a batch file?

Community
  • 1
  • 1
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
0

You can just use a shortcut to the file and add the parameters on the path. no need for an extra batch file.

edit: unless you want to pass the batch file parameters to the .exe, as some people read this. what do you want to do? execute a .exe with the same parameters each time, or pass the .bat parameters to the .exe?

Nzall
  • 3,439
  • 5
  • 29
  • 59