Need help with a .bat file

viNclinedv

Reputable
Jun 18, 2015
29
0
4,560
I'm not too sure where this would go in so I'm just going to leave it here...

I have been playing No Man' Sky lately and started using the Freelook mod, which requires a virtual joystick program, VJoy. Every time I want to use the mod I have to start VJoy and then No Man's Sky, and close both of them when I'm done. I want to make a batch file that can open both of these programs through their shortcuts in the same folder as the .bat file and then close both of them if I close one of them.

*Edit*
Current progress:

@echo off
pushd D:\Program Files\Steam Library\steamapps\common\No Man's Sky\Binaries
start NMSELauncher.exe
pushd C:\Program Files (x86)\VJoy
start VJoy.exe


I am able to get both programs up and running. Now I need to know how to close VJoy once No Man's Sky is closed.

TLDR; I want to write a Batch file that will launch two specific .exe's in different locations or two shortcuts to those .exe's in the same folder and then close both of them when I close one of them.
 
Solution
I ended up writing an AHK script which seemed to work a lot better
Here it is if anyone else needs a script like this.

SetWorkingDir, D:\Program Files\Steam Library\steamapps\common\No Man's Sky\Binaries\
Run, NMSELauncher.exe

SetWorkingDir, C:\Program Files (x86)\VJoy\
Run, VJoy.exe

End::
WinKill No Man's Sky
Process, Close, VJoy.exe
ExitApp
Something like this:

start VJoy.exe
start /wait NMSELLauncher.exe

REM batch file waits here for you to exit NMSELLauncher.exe

taskkill /IM VJoy.exe

Using this, however, requires that you stop NMSELLauncher.exe first to stop VJoy.exe rather than stopping either one.
 


That's exactly what I need. The problem is that the NMSELauncher is basically a second launcher that starts the games executable and injects a few .dll's in order to have some mods in the game running.

So I start NMSELauncher.exe but when I close NMS.exe I want VJoy.exe to close aswell

 
I ended up writing an AHK script which seemed to work a lot better
Here it is if anyone else needs a script like this.

SetWorkingDir, D:\Program Files\Steam Library\steamapps\common\No Man's Sky\Binaries\
Run, NMSELauncher.exe

SetWorkingDir, C:\Program Files (x86)\VJoy\
Run, VJoy.exe

End::
WinKill No Man's Sky
Process, Close, VJoy.exe
ExitApp
 
Solution