0

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
    Possible duplicate of [How to run multiple .BAT files within a .BAT file](http://stackoverflow.com/questions/1103994/how-to-run-multiple-bat-files-within-a-bat-file) – Ross Ridge May 23 '16 at 16:30

1 Answers1

0

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.

Stephan
  • 53,940
  • 10
  • 58
  • 91
  • Thank you very much. Indeed I now realise the control was not in hands of the command file anymore, meaning the "parameters" or inputs were not passed along. However, even when I launch: `cd C:\Users\user\Downloads\megatools-1.9.97-win64\megatools-1.9.97-win64\`
    `call megacmd.bat megals /Root --username username@email.domain --password password`

    The batch file will not excecute the command. It appears I can't figure out how to pass along more than 1 command consecutively.
    – Maximilian brutus III May 09 '16 at 17:37
  • are `megals` and `megamkdir` also batchfiles? Then you have to `call` them too. If your first four code lines run fine when you enter them on command line, then this will probably work. – Stephan May 09 '16 at 19:25
  • Dear Stephan, thank you for your suggestion, they were .exe files. However instead of trying to pass these commands along to the megacmd.bat, I figured I might be more successful at manipulating the batch file so that it would simply run with the commands encoded. And thanks to this wonderful community, I was :) – Maximilian brutus III May 09 '16 at 19:40
  • Yeah - I read your other question. The `@cmd` opened a new instance of the interpreter using the same window, but that was not aware of any following commands, because they stayed within the old instance. – Stephan May 09 '16 at 19:47