vee
vee

Reputation: 429

Run a batch script in another directory than the batch script directory

I have a batch script that I run from the Windows Task Scheduler, the advantage is that the scheduler has the option of "Start in:", this allows me to run the batch script in a totally separate directory.

In the cmd prompt the equivalent would be to open a cmd prompt window in Directory1 and type out the full Directory2/batchscript.bat.

However, I was wondering if there was a way inside my batchscript.bat to set the directory to "run" in?

Upvotes: 1

Views: 5171

Answers (1)

user2956477
user2956477

Reputation: 1350

Try something like this:

set "your_dir=path_to_your_directory"     
pushd %cd%
cd %your_dir%
run_your_command
popd

Upvotes: 2

Related Questions