Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Batch file?  (Read 1884 times)

0 Members and 5 Guests are viewing this topic.

LeedsFan

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1045
  • Last login:February 19, 2026, 12:16:51 pm
Batch file?
« on: February 19, 2026, 07:54:00 am »
Sorry if this is in a wrong forum.

I'm no good at writing stuff like batch files. I did do a google search and AI did come up with something, but said it might not work.

I have a cabinet that has a dedicated dual stick control panel running Win10. It only plays about four games and I don't even want to use a front end.
I'm quite happy for Mame to start on boot and auto run a game.

I can exit game to the Mame menu itself (as only 4 games very short menu).  But on exit of Mame I want the PC to shutdown.

I have no idea how to write this.   :banghead:

Fursphere

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1286
  • Last login:Today at 12:32:53 am
Re: Batch file?
« Reply #1 on: February 19, 2026, 09:16:02 am »
This is a going to be a little clunky...any

I would use autohotkey (AHK).   Then I would ask ChatGPT to write me a script.   I would start with a prompt like this ...

"I need an AHK script.  The script is intended to be run when windows starts.  It should start MAME.   After MAME is running, the script should remain active in the background and poll to see if MAME is still running every 60 seconds.  If MAME is no longer running, open a message box that says "Shutting down PC in 60 seconds" then in 60 seconds, shut down the PC"

You could get fancy and ask it to build an abort process too.     "Shutting down PC in 60 seconds, press any key to abort" (and tell it to cancel the shutdown if a key press is detected).  Maybe if a keypress is detected, start MAME back up.    Or drop to desktop.   Whatever you want it to do. 

Literally tell ChatGPT what you want the script to do, and it'll come up with the code.   (.AHK file).

Then just place this .AHK file in your /startup/ folder (start - run --> shell:startup to open the startup folder)

If it doesn't work, just tell ChatGPT what didn't work.  If it throws an error, give it the error message (you can even take a screenshot and give it the screenshot).  It'll get it working. 

On a side note, if you just want MAME - have you looked at ArcadeEIP ?  https://github.com/gildahl/arcadeEIP

Good luck.   (if you don't have AHK installed, go ahead and install it first.   https://www.autohotkey.com/ )

LeedsFan

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1045
  • Last login:February 19, 2026, 12:16:51 pm
Re: Batch file?
« Reply #2 on: February 19, 2026, 11:52:57 am »
OK now I have a problem.   :cry:

Hmmm....  had PC in a loop of not starting Mame, and then shutting down. I sorted that out though. But the script is throwing up some sort of error which I can't read in time before the box disappears and shutdown starts.

I've checked the Mame.exe path is correct in the script and the rom name is correct.   :dunno

Did I say I had no idea about making these scripts?    :lol

Fursphere

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1286
  • Last login:Today at 12:32:53 am
Re: Batch file?
« Reply #3 on: February 19, 2026, 11:57:24 am »
I think you can hold SHIFT during startup to skip the startup items.   

(You could also ask ChatGPT how to fix this)

thebyter

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 28
  • Last login:Yesterday at 06:42:05 pm
Re: Batch file?
« Reply #4 on: February 19, 2026, 01:44:26 pm »
In my opinion, AutoHotKey feels like overkill for this, especially if you haven't already installed it for anything else.  I'm also not sure it's worth asking AI to build it for you.  8-?  You can probably just put a two-line batch file in your mame directory:
Code: [Select]
c:\NAME\mame.exe <options>
shutdown /f /s /t:60
Shutdown ships with Windows, so you won't need to install anything (except MAME).  The options in this case mean "/force applications to quit while /shutting down the PC, after a 60-second /timeout".  The timeout defaults to thirty seconds, and you can use "/t 0" to shutdown immediately.

If you just want the menu to pop up when MAME starts, leave "<options>" off.  There are a gazillion options to mame, most of which you probably don't need until you get the basics working.  See https://docs.mamedev.org/commandline/.  If you want to automatically run a game instead of seeing the menu first, you can use the driver name instead of (or in addition to)  <options>.  For example:
Code: [Select]
c:\MAME\mame.exe tempest -skip_gameinfoAlthough, if you start it this way, I think exiting the game with <ESC> also exits mame, so it'll just fall through to the shutdown -- you'll never be able to start any other game.  If you want to auto-start a particular game and return to the menu when it exits, I think you'll need to close the game through the <TAB> menu.

Anyway, once you've saved this in a file, called (for instance) letsplay.bat, you can set up a scheduled task to start it whenever you logon.  Use Task Scheduler from the control panel (taskschd.msc) or schtasks.exe from the command line.
Code: [Select]
schtasks /create /tn "Start MAME" /tr c:\MAME\letsplay.bat /sc onlogonThe GUI's probably going to be easier to understand, though.  You only need to add this scheduled task once, of course, not every time you run mame or anything.

Good luck!
« Last Edit: February 19, 2026, 05:26:39 pm by thebyter »