1

I have Oddworld Abe's Oddysey but the game didn't work well with my GamePad so I had to use Joy2Key, I created a .bat to start both processes but It doesn't work as I want to.

I want that when I stop playing the game make the process JoyToKey.exe end, but I can't get it to work with my code, what should I do?

start JoyToKey_en\JoyToKey.exe
start /wait AbeWin.exe
taskkill /f /im JoyToKey.exe
AlexTCGPro
  • 31
  • 8

2 Answers2

0

This an example that show you how to check if a process like (AcroRd32.exe) (Adobe Reader) is running or not, so if isn't running the script try to start it and of course you can kill it after stating it !

@echo off
Title Check process for starting
mode con cols=65 lines=5 & color 9B
Set ProcessPath=%ProgramFiles%\Adobe\Reader 11.0\Reader
set ProcessName=AcroRd32.exe
Tasklist /nh /fi "imagename eq %ProcessName%" | find /i "%ProcessName%" >nul && (
    echo %ProcessName% is started
) || (
    echo %ProcessName% is not started & Start "" "%ProcessPath%\%ProcessName%"
) 
pause
Echo Killing %ProcessName%
Taskkill /IM "%ProcessName%" /F
pause

And this Batch is with menu :

@Echo off & cls & color 0B
Mode con cols=72 lines=10
Set TmpFile=TmpFile.txt
Set Resultat=KillResult.txt
If Exist %TmpFile% Del %TmpFile%
If Exist %Resultat% Del %Resultat%
:menuLOOP
Cls & color 0B
Title Process Starter and Killer by Hackoo 2015
echo.
echo.      ==========================Menu============================
echo.
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~f0""') do echo.           %%B  %%C
echo.
echo.      ==========================================================
set choice=
echo. & set /p choice=Make a choice or hit ENTER to quit: || GOTO :EOF
echo. & call :menu_%choice%
GOTO:menuLOOP
::********************************************************************************************
:menu_1 StartMyProcess
cls & color 0B
echo.
Set /p "MyProcess=Enter the process name  "
echo.
echo The process %MyProcess% is started ... 
Start %MyProcess%
GOTO :menuLOOP
::********************************************************************************************
:menu_2 KillProcess
Title Process Killer by Hackoo 2015
cls & color 0B
echo.
echo                What process do you want to kill ?
echo.
set/p "process=Enter the name of the process> "
cls & color 0C
Title Killing "%process%" ...
echo.
echo                       Killing "%process%" ...
echo.
echo %date% *** %time% >> %TmpFile%
For %%a in (%process%) Do Call :KillMyProcess %%a
Cmd /U /C Type %TmpFile% > %Resultat%
Start %Resultat%
GOTO :menuLOOP
::*********************************************************************************************
:KillMyProcess
Taskkill /IM "%~1" /F >> %TmpFile% 2>&1
echo ***************************************************************************** >> %TmpFile%
exit /b 
::*********************************************************************************************
:EOF
EXIT
Hackoo
  • 18,337
  • 3
  • 40
  • 70
0

your code should work check the script log by removing an @echo off (if you have that) and putting a pause at the end see what error it spits out and it you cant figure out how to solve the problem then post a pic of the console and ill se if i can see whats wrong

[Edit]

Try this i tested it and it worked show me the console if it still does not work

start JoyToKey_en\JoyToKey.exe
echo n | start /wait AbeWin.exe
taskkill /f /im JoyToKey.exe
Luke McGregor
  • 36
  • 1
  • 5