Question Open and close a program depending on a game ?

Jun 10, 2023
1
0
10
Hi, this is my first post, so please correct me if I'm in the wrong category etc.

So basically I am trying to modify the code from this thread:
- https://forums.tomshardware.com/thr...nd-closes-respectively.3301639/#post-20193797

The code should open osu!.exe aswell as Keyoverlay.exe, wait until osu!.exe is closed and close keyoverlay.exe thereafter. My try at this ends up looking like this:

[
@Echo off
start "F:\archive\osu-stuff\kkeyoverlay\KeyOverlay.exe"
start /wait "" "C:\Users\name\AppData\Local\osu!\osu!.exe"
taskkill /IM KeyOverlay.exe
exit
]

When the .bat file is started, osu!.exe opens up, as well as the corresponding cmd process, which closes When the game is closed. The problem I'm facing now, is that keyoverlay.exe is not opening and another cmd process opening but not closing, which just shows the lines:

F:\archive\osu-stuff\bat>

This is where the .bat file is saved.

It doesn't appear to be doing anything. This process also does not close when exiting the game.
If possible I'd like the cmd processes to not be shown aswell, to make it look better. I've done this on another project by using this code:

[ CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False ]

which was then used like this:

[ wscript.exe "line-from-above" "other-code" ]

Is that possible in this case aswell, or do I need another way of sorting this out ?
I tried varying the location of the program, just out of curiosity as well as switching the order of the code.
I have zero clue of what I'm doing and am just pasting code, so please dont bash me if its obvious.

Any help is greatly appreciated !
 
The problem I'm facing now, is that keyoverlay.exe is not opening
Is the path to keyoverlay.exe correct in the batch file?
You are using two k's in the path.

F:\archive\osu-stuff\kkeyoverlay\KeyOverlay.exe

Also, I just noticed that the /wait parameter doesn't work with these newer (cheesy, cheap looking) Windows store apps such as Calculator (calc.exe).

The following seems to work in Windows 11:
Code:
@echo off
start notepad.exe
start /wait "" "regedit.exe"
taskkill /f /IM notepad.exe
You are expected to manually close out Regedit, then Notepad will auto-close.

Also, you can create a shortcut to the batch file, and in the Properties for the shortcut, set it to Run Minimized. This will run the command prompt in a minimize window (where the batch file runs).
 
Use a scripting language for this

You don’t use kitchen cutlery to perform surgery, use the right tools
 
I played around years ago with something similar and I did it with task scheduler. I created a task that said when I opened a specific program to open another. I did not autoclose it but should do it as well with a new task.

This was on win 7 back in the day but might still work. Worth a shot anyway since it's so much easier than scripting it.