简体   繁体   中英

How to set a go to a directory and execute a command in a batch file?

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屏幕截图

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM