Solved Call a game shortcut, run a batch file when the game exits

February 11, 2015 at 16:30:06
Specs: Windows 7
Playing a new game in which the developers have restricted the save games to two slots (FC4). There have already been many reported issues with the save games being corrupted and players having to start over from scratch. I have a batch file to copy the save games to a different dir and append a date/time stamp to them. In order to avoid the need to manually run the bat file after the game exits, I would like to create a shortcut that will start the game, then after the game exits, make a backup of the saves.

See More: Call a game shortcut, run a batch file when the game exits

Report •

✔ Best Answer
February 16, 2015 at 09:30:24
You typically can't just run the program and expect the script to wait. Once STD I/O is released, your script is going to continue. The easiest way to work around this is to tell CMD to wait until the program exits.

start "" /w /d "<game shortcut's start in>" <game shortcut's target>

How To Ask Questions The Smart Way



#1
February 11, 2015 at 17:26:16
I think you will do better on the Programming forum for this one - I'll alert the mods to see if they think it best to shift it over there. You should still be able to access it.

Always pop back and let us know the outcome - thanks


Report •

#2
February 11, 2015 at 20:34:00
Just some general info: In a regular dos batch file you'd just have the exe file that starts the game as its first line. Then when the game is concluded the batch file runs the next commands. I'm not sure if it's exactly the same in a windows environment. But try modifying the batch file you have now to add that line.

If backing up the saved information isn't part of the file now it seems like all you need to do is add a line to COPY the files containing that information to wherever you wanted them. Of course you need to include the path information for the exe file to start the program and when copying the saved information.


Report •

#3
February 12, 2015 at 04:36:59
Unfortunately it looks as if just adding the start command at the head of the batch file didnt work. The game started but the files weren't backed up when I exited the game.

Report •

Related Solutions

#4
February 12, 2015 at 07:17:16
Hi DAVEINCAPS

Yep, something like:

========= script
mygame.exe
copy [the info] D:\files\saved.txt
@echo %DATE% %TIME% >> D:\files\saved.txt

=====================

M2 Get custom script or take private lessons


Report •

#5
February 12, 2015 at 22:53:20
Hey, our forum paths don't cross that often. Looks like this got moved to programming.

Report •

#6
February 16, 2015 at 09:30:24
✔ Best Answer
You typically can't just run the program and expect the script to wait. Once STD I/O is released, your script is going to continue. The easiest way to work around this is to tell CMD to wait until the program exits.

start "" /w /d "<game shortcut's start in>" <game shortcut's target>

How To Ask Questions The Smart Way


Report •

Ask Question