Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to start multiple instances of a command line application with a batch file?  (Read 13067 times)

0 Members and 1 Guest are viewing this topic.

JRobinson

    Topic Starter


    Rookie
    • Yes
  • Experience: Beginner
  • OS: Windows 7
I'm using resample.exe for Flight Simulator to resample imagery that shows in the sim as photoreal terrain. You use an .inf to specify the sources (.tifs plus their respective geographic information) and output (path\to\output.bgl). Normally I use a "Send to" command on my right click menu where I can select an .inf, right click, and "Send to > resample.exe". That works fine but now I have multiple .infs that I'd like to resample simultaneously so I have to select each one in turn and send them to resample. Resample is very slow and uses only about 10% of one core on the CPU so it's possible to hurry things along quite a bit by running multiple instances, each working on different parts of the project. I'm trying to come up with a batch file that will spin off multiple instances of resample.exe each in it's own window, here's what a typical batch file resample command looks like:

Code: [Select]
"C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140308.inf
That command just causes resample to run in the same window the command was issued from and I use it with pause for troubleshooting. Pause holds the window open so you can read the error where when using the Send-to shortcut the DOS window just flashes and closes immediately in the event of an error.

...so I tried this:

Code: [Select]
start "C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140308.inf
start "C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140309.inf

...but that merely opened each .inf in a separate Notepad window. I tried:

Code: [Select]
start cmd "C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140308.inf
start cmd"C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140309.inf

...and

Code: [Select]
start cmd /"C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140308.inf
start cmd /"C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140309.inf

...and

Code: [Select]
start "C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe":klam_1m_WGS84_03140308.inf
start "C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe":klam_1m_WGS84_03140309.inf

...all of the above did something, just not what I wanted, lol.

Obviously I don't know what I'm doing and Start /? merely caused my eyes to glaze over. :)


Can I get a little help from the experts here?

Thanks much,
Jim

JRobinson

    Topic Starter


    Rookie
    • Yes
  • Experience: Beginner
  • OS: Windows 7
It seems I have this sorted:

Code: [Select]
start cmd /k "C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140308.inf
start cmd /k "C:\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Terrain SDK\resample.exe" klam_1m_WGS84_03140309.inf

...spins off two new cmd windows each resampling different parts of the imagery.

More details if anyone's curious:
The entire project currently uses 92 sources (.tifs) at roughly 1.1 Gb apiece. The simulator has a limitation where a .bgl can't exceed 2 Gb or it won't show. Resample has an option for "SplitFileLOD" where it will split large projects like this up into smaller .bgls to avoid exceeding the 2 Gb limitation, I'm using SplitFileLOD=9 where it splits the .bgls at LOD9 boundaries which are approximately 13 miles across in both the X and Y directions. The 92 sources are split into 31 separate .bgls using SplitFileLOD=9. Resample also has an option for "BoundingCell" where you can constrain the output to a particular cell, BoundingCell=11,314,308 for example causes resample.exe to resample just one of the 31 .bgls that make up the project (klam_photo_1m_03140308.bgl). If I leave BoundingCell out of the .inf resample will start at the top left corner and resample each of the 31 .bgls in turn until it finishes the project. That means it's bedtime because last I checked it takes a little over 4 hrs to do that, lol.

Being able to spin this off into multiple instances, maybe six instances at a time to get the CPU load up somewhere near 100%, I can cut that resampling time down significantly. Also if I make edits to just one or two .tifs I can resample only the .bgl affected by those .tifs I've edited rather than having to resample the whole lot at once.

Thanks for checking this thread out folks. I think I'm good to go now. :)
Jim