Reputation: 432
i have created a batch file(suppose batch1) which is in a folder(suppose folder A) and is programmed to start another batch(suppose batch2) which is in another directory(suppose folder B). Batch2 is programmed to extract a file(suppose xyz.tar which is both in folder A and B). But when i start batch1 it starts batch2 but batch2 extracts the file in folder A not in B. The examples below can help you to understand.
Here are my batch files.
::batch1
ECHO This is batch1
"D:\folder B\batch2.bat"
::batch2
ECHO This is batch2
7z.exe x xyz.tar >nul
Folder A contains batch1.bat and xyz.tar.
Folder B contains batch2.bat and xyz.tar.
batch2 starts but it starts extracting the file which is in folder A but it should extract the xyz.tar in the folder B.
Upvotes: 0
Views: 110
Reputation: 79983
At the start of your batch2.bat, after your @echo off/setlocal
try
cd /d "%~dp0"
Upvotes: 2
Reputation: 3945
I think that you must change the working folder to extract at the correct position.
try something like:
cd "d:\folder B"
batch2.bat
Upvotes: 1