0

During the deployment of the windows application that I make, I have to run a few commands in the CommandPrompt to update the database. I was thinking of making a batch file to automate this process so that the user can update the database just by double-clicking the batch file. Following is the screenshot for the same.

CommandPrompt Screenshot

I want my batch file to go to the current directory where the .bat file is located. Then i want to execute the DBUpdater exe file against the config file.

I am new to batch programming so anything informative will help a lot. Thank you.

taimur alam
  • 564
  • 7
  • 19

1 Answers1

0

Create a batch file named DBUpdater.bat in any directory of your choice with the below script:

@ECHO OFF
setlocal
cd /d %~dp0
DBUpdater.v15.2.exe OfficeManagement.win.exe.config

This assumes that the OfficeManagement.win.exe.config file exists in the same directory as batch file and that DBUpdater.v15.2.exe is recognized as a global command.

Learner
  • 209
  • 2
  • 12
  • Thank you so much, it worked like Magic. Would you care more into explaining how each of these symbols work? It'll be a huge gainer for me. – taimur alam Dec 27 '17 at 07:40
  • @taimuralam - Please check this [post](https://stackoverflow.com/questions/4419868/what-is-the-current-directory-in-a-batch-file) to see how I go to the current directory. – Learner Dec 27 '17 at 07:47
  • please go to command prompt and enter `HELP CALL` for useful Information about that symbols :-) – loco Dec 27 '17 at 09:00
  • Do i not have to use anymore ECHO and EXIT commands after the last line – taimur alam Dec 27 '17 at 10:53
  • @taimuralam - That's not required if your application launches in background. If it doesn't, you may need to launch it in a separate command prompt and exit the one running this batch script. Feel free to customize it as per your needs. – Learner Dec 27 '17 at 11:13