0

I am vaguely familiar with batch. Super light knowledge. Anyways, I have this program that runs in a command line mode (it happens to render minecraft maps). It is normally used by opening cmd, and typing mapcrafter.exe -c config.config -j 8 which runs the exe, specifies the config file, and runs the job with 8 threads.

One thing I wanted to do was put all of this in a batch file so I didn't have to type everything in every time I wanted to re-render it. It looked like:

start cmd.exe /K mapcrafter.exe --config "config.config" --jobs 8

This worked great, when the batch file was in the same directory as the exe. Anyways, what I don't know how to do is to:

  1. Start command prompt
  2. change directory (cd) to the folder containing the .exe
  3. Run the .exe with the two (-c -j) parameters

I want to do all of this in one batch file, and I want it to keep the command prompt window open, since the .exe outputs errors and percent completion.

I'm lucky I was able to get the one-line batch file working, with my limited knowledge of batch. At this point, I'm out of ideas as to how I should approach this. Thank you in advance for any help you can offer!

Dirttraxx
  • 7
  • 1
  • 6

2 Answers2

1

Why don't you just create a batch file with

mapcrafter.exe --config "config.config" --jobs 8

The reason it doesn't work when it is not in the same directory is because your path variable doesn't have the location of mapcrafter. An easier way around would be to use full path something like

D:\MineCraft\mapcrafter.exe --config "config.config" --jobs 8

If you want to learn more about configuring PATH environment variable see Adding directory to PATH Environment Variable in Windows

Community
  • 1
  • 1
Learner
  • 212
  • 2
  • 6
  • 2
    If you don't want to edit the system path variable you can also write `set path=%path%;D:\MineCraft` in your batch file. This will add the directory to the path just for the context of the batch file (and processes spawned by it). – Lukas Thomsen Oct 29 '14 at 04:25
  • When I do `D:\MineCraft\mapcrafter.exe --config "config.config" --jobs 8` I get a console window that flashes `D:\MineCraft\Renders\Specific job folder>D:\MineCraft\mapcrafter.exe --config "config.config" --jobs 8 "D:\Minecraft" is not recognized as an internal or external command, operable program or batch file` – Dirttraxx Oct 29 '14 at 22:22
  • I tried typing everything manually into command prompt. It chokes on the path for the config file. When I type in `"D:\MineCraft\Renders\Specific job folder\config.config"` after the `-c` or `--config` parameter, I get feedback that the argument `<"D:\MineCraft\Renders\Specific job folder\config.config">` is invalid for the parameter `-c` or `--config` – Dirttraxx Oct 29 '14 at 22:57
  • Same for an application shortcut. The code is practically the same anyways. `"D:\MineCraft\mapcrafter.exe" -c "D:\MineCraft\Renders\Specific job folder\config.config" -j 8` – Dirttraxx Oct 29 '14 at 22:59
  • 1
    Apparently I couldn't use spaces in filepaths. ended up using: `cd "D:\Minecraft\" mapcrafter.exe -c "Renders\Specificjobfolder\config.config" -j 8' in a batch file. I talked with the programmer, and it is now something he is trying to fix. – Dirttraxx Oct 30 '14 at 01:01
0

you could just make a shortcut of the .bat file and have that on your desktop or wherever you want it. here is Microsoft's support page on this http://support.microsoft.com/kb/140443

kuthedk
  • 153
  • 1
  • 11