Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Can someone tell me what do I need to write in [X] to make the process Maplestory.exe be killed when it will start? I don't want to use timing commands, thanks! (the gamelauncher.exe causes the maplestory.exe to run)

@echo off
start D:\Games\MapleStory\GameLauncher.exe
[X]
taskkill /im MapleStory.exe
exit

share|improve this question
add comment

2 Answers

I would pipe the output from tasklist into find, search for maplestory, and use an IF statement and a GOTO to continue looping, checking for that process, until it's found. Once it's found, then you can GOTO a different point to kill the task.

Something like this should do the trick:

:search
tasklist|find "maple"
IF %ERRORLEVEL% = 0 THEN (GOTO found)
TIMEOUT /T 1
GOTO search

:found
taskkill /im maplestory.exe

(The TIMEOUT command pauses the script for 1 second. This will help prevent it from sucking up too much CPU constantly running that loop.)

share|improve this answer
add comment

Why must you run anything? You can simply attempt to terminate the process at any time and then take action upon success (&& operator) or failure (|| operator). You can simply loop via GOTO until you achieve success.

@echo off
start D:\Games\MapleStory\GameLauncher.exe
:killMapleStory
taskkill /im MapleStory.exe >nul 2>nul || goto killMapleStory
exit

You might want to introduce a 1 second delay into the loop just to conserve CPU resources. MapleStory will never run for more than ~1 second.

@echo off
start D:\Games\MapleStory\GameLauncher.exe
:killMapleStory
timeout /t 1 /nobreak >nul
taskkill /im MapleStory.exe >nul 2>nul || goto killMapleStory
exit
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.