Skip to content
WJunction - Webmaster Forum

Execute .bat from another .bat

Status
Not open for further replies.
So, i have one bat file with some commands in it, and I want to add next:

I have folder on different drive, that contains some folder that have to be deleted, and I made another do.bat in that folder with command:

Code:
for /d %%a in (?*FAILED*) do rd /s /q "%%a"

so, this deletes all subfolders, and files, where that do.bat is present

Well, I want to execute it from another .bat file, which is on different drive

I've tried with

call d:\temp\blah\here\do.bat

but it doesn't work, at least doesn't execute do.bat same way, when I start it manually.

shortest version: I start .bat file from c: drive, which executes another .bat file on d: drive

Any ideas?
 
Last edited:

11 comments

tried start too, with and without quotes, I know quotes are used when there is space inside folder name/path

Major problem here is, that do.bat, needs to be executed within the folder where it's called from, and function inside bat must be executed same way, like I double clicked on do.bat

Problem here is, that do.bat is executed, but function inside it, is executed inside folder where original bat, which calls do.bat, is.
Maybe other solution would be, not having do.bat, and call just one bat, which executes this command

for /d %%a in (?*FAILED*) do rd /s /q "%%a"

but I dunno how to apply it to be executed on, for example, d:\somefolder\anotherone

9WxBf.jpg
 
Last edited:
Code:
D:
cd "Path\to folder\where bat is"
myfile.bat

Put the above in a file 'source.bat' and run that from any location. Check if it works. It should, theoretically.
 
Last edited:
Status
Not open for further replies.

About the author

C
Active Member · Joined
5,788
Messages
4,363
Reactions
113
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom