Create a Batch File to Close/Launch/Reopen Programs

In summary, the conversation discusses the challenge of creating a batch file that can close certain programs, launch a game, and then reopen those programs upon exit of the game. There is uncertainty about whether this is possible and suggestions are made about using a different language, such as VBScript, to achieve this goal.
  • #1
jpfuse
1
0
i don't know if this is even the right forum but i am trying to right a batch file which will close certain running programs, launch a game, and upon exit of the game, run the programs that were closed. i know how to close a prog and open the game, but i don't know how to run the progs when the game exits.
 
Computer science news on Phys.org
  • #2
i don't know if this is even the right forum but i am trying to right a batch file which will close certain running programs, launch a game, and upon exit of the game, run the programs that were closed. i know how to close a prog and open the game, but i don't know how to run the progs when the game exits.

I'm not real sure if that is doable, unless the game sends some kind of code on exit that could execute a batch file.

What game is it? What programs? Perhaps your best bet would be to simply create a batch file that executes your programs, then use this to start the programs, and a command within this batch starts the game and closes the programs.

As to restarting the programs when the game exits, I'm stumped.
 
  • #3
I'm with Megashawn. You need some sort of event synchronization that runs when the game is shut down. What you are doing is beyond the scope of a batch file. Batch files are for triggering a series of events, not being triggered by those events. Although they can be made to have some structure, I recommend looking at something like VBScript that was meant for these kind of things.
 

1. How do I create a batch file?

To create a batch file, you can use any text editor such as Notepad or Notepad++. Simply open the text editor, type in the commands you want the batch file to execute, and save the file with a .bat extension.

2. How do I close a program using a batch file?

To close a program using a batch file, you can use the "taskkill" command followed by the name of the program. For example, if you want to close Google Chrome, the command would be "taskkill /IM chrome.exe".

3. How do I launch a program using a batch file?

To launch a program using a batch file, you can use the "start" command followed by the path to the program. For example, if you want to launch Microsoft Word, the command would be "start C:\Program Files\Microsoft Office\Word.exe".

4. How do I reopen a program using a batch file?

To reopen a program using a batch file, you can use the same command as launching a program. However, you may need to add a pause in between the "start" command and the program's path to ensure the program has enough time to fully close before reopening.

5. Can I create a batch file to close/launch/reopen multiple programs at once?

Yes, you can create a batch file to close, launch, and reopen multiple programs at once by using the appropriate commands for each action. Make sure to add a pause in between each command to allow each action to fully execute before moving on to the next one.

Similar threads

Replies
19
Views
1K
  • Computing and Technology
Replies
9
Views
904
  • Computing and Technology
Replies
3
Views
933
  • Computing and Technology
Replies
3
Views
2K
  • Computing and Technology
Replies
20
Views
581
  • Computing and Technology
Replies
1
Views
1K
Replies
15
Views
4K
  • Computing and Technology
Replies
6
Views
941
  • Computing and Technology
Replies
24
Views
7K
Replies
8
Views
578
Back
Top