Author Topic: Attract mode terminates script/batch but not emulator!!  (Read 2671 times)

tommy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Attract mode terminates script/batch but not emulator!!
« on: May 22, 2021, 04:32:53 AM »
Well, this issue makes perfect logical sense but I wonder how to solve it. It is so basic I am surprised I failed to see someone else discuss it here (unless if I missed the thread)

As you probably all do, I sometimes use a batch or script to launch an emulator

ex
Batch file to launch dos box with a particular game
script file to launch Nintendo DS emulator then send Alt+Enter to maximise it

Issue is that the batch/script IS the executable file from AM's point of view

So when I press the exit hotkey, AM immediately terminates the batch file, but it doesn't terminate the ACTUAL EMULATOR EXE file

An example

I launch Keen (Dos Game) with a batch file that invokes Dosbox with the keen.exe file as a parameter

when I press the hotkey to terminate and return to AM, the batch file is terminated, but dosbox is still running in the background, and now I have so much noise because there is the video of keen playing on AM + the music of the actual game running in dosbox the background.

Is there a solution to this? Can I (somehow) program AM to terminate batch file PLUS dos box or go.vbs (script) PLUS Desmume?

Thanks heaps!

tommy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #1 on: May 26, 2021, 02:31:11 AM »
Let me ask it in another way:

When you press the exit hotkey set by attract mode, it immediately terminates the executable (that was set in settings)
but can I make it terminate  more than one file? i.e the batch file (executable) PLUS the actual executable of the emulator

jedione

  • Hero Member
  • *****
  • Posts: 1100
  • punktoe
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #2 on: May 26, 2021, 06:19:51 AM »
why not just use dosbox pure,  via retroarch....it works so good...
help a friend....

tommy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #3 on: May 26, 2021, 06:37:43 AM »
Thanks for the reply but this is for my bartop that i built on an old laptop and there is an issue with the graphic driver that makes retroarch crash all the time :(

i.e so I am stuck with dosbox on its own

rand0m

  • Sr. Member
  • ****
  • Posts: 354
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #4 on: May 26, 2021, 11:02:29 AM »
1- Use start /wait for running dosbox
2- Create another bat file for terminating dosbox and call it at the end. Something like following where dosbox.exe is the main executable:
     
Code: [Select]
taskkill /IM dosbox.exe /F
exit

tommy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #5 on: May 26, 2021, 04:54:33 PM »
1- Use start /wait for running dosbox
2- Create another bat file for terminating dosbox and call it at the end. Something like following where dosbox.exe is the main executable:
     
Code: [Select]
taskkill /IM dosbox.exe /F
exit

Perfect, but how do I call this batch file that terminates dosbox?
i.e is there a way to get AM to EXECUTE the batch file when i press the EXIT hotkey to close the emulator?
Thanks

jedione

  • Hero Member
  • *****
  • Posts: 1100
  • punktoe
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #6 on: May 26, 2021, 05:33:11 PM »
help a friend....

jedione

  • Hero Member
  • *****
  • Posts: 1100
  • punktoe
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #7 on: May 26, 2021, 05:39:38 PM »
just my 2 cents, but somtime this old pc stuff might be time to go...i love to repurpose things...

but im thinking a pi3 might be like 40$ and you could use the screen from the old computer...

anyway  back to work so i can by a new pc.....lol   hope that helps
help a friend....

kent79

  • Hero Member
  • *****
  • Posts: 808
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #8 on: May 26, 2021, 06:28:51 PM »
why not just use dosbox pure,  via retroarch....it works so good...

Dosbox pure is not the best choice in this moment, I can't play some game in it.  Dosbox core is the best  :)

rand0m

  • Sr. Member
  • ****
  • Posts: 354
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #9 on: May 26, 2021, 07:11:09 PM »
1- Use start /wait for running dosbox
2- Create another bat file for terminating dosbox and call it at the end. Something like following where dosbox.exe is the main executable:
     
Code: [Select]
taskkill /IM dosbox.exe /F
exit

Perfect, but how do I call this batch file that terminates dosbox?
i.e is there a way to get AM to EXECUTE the batch file when i press the EXIT hotkey to close the emulator?
Thanks

You can create a dosbox.bat in dosbox folder and call it from there. What is the "executable" and "args" in dosbox emulator.cfg? Since dosbox already supports an exit function, it would be best to simply add -exit if you start dosbox directly e.g:
Code: [Select]
executable           d:\games\dos\dosbox\dosbox.exe -exit -fullscreenif spaces in path, use:
Code: [Select]
executable           "d:\games\dos\dos space box\dosbox.exe" -exit
If you start dosbox via batch then add -exit after dosbox.exe then rest of the command e.g.:
dosbox.bat (launches dosbox)
Code: [Select]
@echo off
start /d "d:\games\dos\dosbox" dosbox.exe -exit %1

This will exit dosbox when you exit the game.

« Last Edit: May 26, 2021, 07:57:54 PM by rand0m »

tommy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #10 on: May 27, 2021, 05:06:14 AM »

If you start dosbox via batch then add -exit after dosbox.exe then rest of the command e.g.:
dosbox.bat (launches dosbox)
Code: [Select]
@echo off
start /d "d:\games\dos\dosbox" dosbox.exe -exit %1

This will exit dosbox when you exit the game.

Yes it will. But only if I normally exit the game. ie. by pressing escape then confirming exit with "y"...etc

What I want is a way to terminate Dosbox even if I exit with AM's HOT KEY that terminates the emulator immediately.
It terminates the batch file that starts dosbox, but not dosbox itself.

I am not sure if I'm making my problem clear to you? Sorry english is not my first language.

rand0m

  • Sr. Member
  • ****
  • Posts: 354
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #11 on: May 27, 2021, 11:35:54 AM »
I got it working on my end, pressing exit_key will quit dosbox and turn teh focus back on AM. What are the "executable" and "args" you are using in emulator for dosbox (in AM/emulators)?

hermine.potter

  • Hero Member
  • *****
  • Posts: 769
    • View Profile
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM

tommy

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Attract mode terminates script/batch but not emulator!!
« Reply #13 on: May 28, 2021, 03:17:10 AM »
Have a look to similar batch problems

THIS! I always knew the best way to do it is to be able to execute a batch file on emulator exit but I didn't know how to do it. This plugin was exactly what I was looking for. I am putting the link below for future reference for anybody who has my same issue.

Thanks heaps to everybody who commented and special thanks for Hermine and rand0m
http://forum.attractmode.org/index.php?topic=3918.0

Edit:
To be more precise, I made a file called after.bat and placed rand0m's code in it
taskkill /IM dosbox.exe /F
exit

and this way attract mode called it every time after a dos game was terminated
« Last Edit: May 28, 2021, 05:18:45 AM by tommy »