Automated running .bat with commands

2019-09-05 21:30发布

I have a automated.bat with the following lines:

cd C:\Users\user\Downloads\megatools-1.9.97-win64\megatools-1.9.97-win64\
megacmd.bat
megals /Root --username username@email.domain --password password
megamkdir /Root/testmake2 --username username@email.domain --password password

It will happily say the megacmd.bat is Megatools Shell, but then it won't excecute the commands that follow.

I figured it might be because the megacmd.bat is in a different programming language, hence the incomming commands aren't valid.

So I tried to fit it all in 1 line with:

cd C:\Users\a\Downloads\megatools-1.9.97-win64\megatools-1.9.97-win64\
megacmd.bat & megals /Root --username username@email.domain --password password & megamkdir /Root/testmake2 --username username@email.domain --password password

but that didn't do anything with the commands either so I also tried:

cd C:\Users\a\Downloads\megatools-1.9.97-win64\megatools-1.9.97-win64\
megacmd.bat & "megals /Root --username username@email.domain --password password" & "megamkdir /Root/testmake2 --username username@email.domain --password password"

And

cd C:\Users\a\Downloads\megatools-1.9.97-win64\megatools-1.9.97-win64\
megacmd.bat "megals /Root --username username@email.domain --password password" & "megamkdir /Root/testmake2 --username username@email.domain --password password"

And

cd C:\Users\a\Downloads\megatools-1.9.97-win64\megatools-1.9.97-win64\
megacmd.bat megals /Root --username username@email.domain --password password & megamkdir /Root/testmake2 --username username@email.domain --password password

But I can't seem to get the syntax right. What would be the command to have the megacmd.bat run and execute the above 2 commands consecutively?

1条回答
孤傲高冷的网名
2楼-- · 2019-09-05 21:58

your line

megacmd.bat

starts megacmd.bat and gives control to it. It never returns to your automated.bat.

You should

call megacmd.bat

to return control to your first .bat after megacmd.bat finishes.

查看更多
登录 后发表回答