0

So i'm unfortunately not a coder (yet, i'll be starting learning windows c++ in a couple of months), and i'd like to understand more how batch files work by doing something like this :

Basically, when i start 2 programs (here, Fortnite and a script alongside) with a selfmade batch file, i'd like the script to be killed ONLY when/after i exit Fortnite.

I've tried 2 methods :

  1. http://prntscr.com/kai6iy (start /wait) -

  2. http://prntscr.com/kai68g (:waitForExit)

Is there something i'm doing wrong? the 1st method just doesn't kill the script when i exit Fortnite, and the 2nd one instantly kills the script in a millisecond, way before Fortnite has even started! :/

I don't know anything windows-related right now! Only started objective-c for mac yet.

Nisarg
  • 1,631
  • 6
  • 19
  • 31
Oscar
  • 11
  • 1
  • 2

1 Answers1

0

You did not provide any output so it is hard to guess, but try adding /t and /f to the taskkill command and see if it helps. I was able to make it work with Notepad and Calculator. If the code below still does not work please be sure to post any errors you are getting. We will need more info.

Your code would be:

@echo off

cd C:\Users\odile\Documents\SCRIPTS
start /b fortnitecp.exe
cd "C:\Program Files\Fortnite\FortniteGame\Binaries\Win64"
start /wait FortniteClient-Win64-Shipping.exe
taskkill /IM fortnitecp.exe /T /F

(I also added quotes around the second path since it has spaces)

  • Hey, so i've added /f to force kill the script, and actually it works! (it takes about 20 seconds to kill it, but it works). thank you so much! i didn't think that would change anything, but yeah since it runs in the background with start /b it may explain why. Btw, i agree that i should have added quotes to the 2nd cd command, but weirdly fortnite opens and everything works fine in either case :P – Oscar Jul 24 '18 at 19:03
  • Glad it worked. Please don't forget to accept the answer when the timer is up, and welcome to SO! –  Jul 24 '18 at 19:04