I would like to have another program (FileSync) open automatically when executing a specific program (let's say for example Minecraft).
And if, for example, I close Minecraft, this program should run out or the task should be finished.
Is this with a batch programming or somehow easier?
And if that goes to batch, where exactly should I put this so that the computer automatically executes that when I open Minecraft?
You would open the batch file directly and then the other two. Automatically quit by checking in a loop, if one task is still running and the other ends accordingly.
OK, sounds good. How can I script this? Unfortunately I know only in c ++ well. Could create a c ++ script but do not know how well windows tolerate that
I'm on my cell phone, but I can talk myself tomorrow night, if no one else has sent a code.
Thank you.
You have a small mistake in your concept.
You want a batch on your PC waiting for you to open Minecraft at some point and then make a backup of your savegames on the Google server…
That is feasible, but would constantly consume a batch of resources on your computer.
It would be much easier if the batch just starts Filesync and Minecraft in parallel… And a certain time after quitting Minecraft (Filesyc should also have time to upload everything) synonymous Filesync finished.
Instead of starting Minecraft via your desktop link or whatever, you start the batch, which does the rest. Quite simple and functional.
Unfortunately, I do not use Minecraft or Filesync and do not know the installation paths and call parameters of the programs, so at best I can do a simulation of the whole thing with other programs, which are available on every computer.
Instead of filesync I start and stop the Windowscalculator. Instead of Minecraft the editor…
Just finish the editor, the calculator will close automatically 10 seconds later.
demo.cmd:
@echo off
echo start filesync (sybolized by the calculator!)
start "" Calc.exe "
Give some time to start
timeout 3> no
echo imagine Notepad would be Minecraft…
echo start Notepad and wait until it closes…
notepad
what follows is done after closing Notepad
echo Notepad has ended.
echo is waiting 10 seconds for Filsync (the calculator) to do his job safely…
Timeout 10
echo echo finish filesync. The calculator…
rem under Win10 is, for whatever reason, from calc.exe in the Taskmanager "Calculator.exe"
under Win7, close the line to quit: taskkill / f / in "Calc.exe"
taskkill / f / in "Calculator.exe"
pause
Unfortunately, I can't do much more without exact information about your programs.
As far as the right approach is concerned, as batch will not continue until after the called program is finished, you do not even have to check if it's still working…;), the next command will not be executed until the previous one is done…
The situation is different if a program is executed with "start", then the batch does not wait for its completion.
Save this batch script to any folder and create a shortcut. Call this, for example, Minecraft and even make the ico on it and pull to the place where the Minecraft shortcut is located. Then you will not have any problems with it
(super script @ oresel.)
Oha this script is divine.
I like your concept the most.
I would need the path of Minecraft and FileSnyc.
Actually you can adjust the code yourself (lines 1, 2 and 4)
start "" FileSync "
start "" / wait "Minecraft"
timeout / t 1
taskkill / f / in "FileSync"
If FileSync takes a while to copy everything, you just have to extend the timeout.
I already totally forgot that wait argument.
The start / far is unnecessary. This would decouple the called program from the batch and might not have access to program-modified environment variables.
If you want to wait for the completion of a program, the bare call of "myPrgramm.exe" without start is sufficient.
There are rare exceptions, but they are not relevant here.
It should work that way for Minecraft too.