Hello Guest it is June 18, 2025, 12:04:53 AM

Author Topic: Call a DOS batch script (.bat) from a macro  (Read 5871 times)

0 Members and 1 Guest are viewing this topic.

Call a DOS batch script (.bat) from a macro
« on: June 12, 2024, 05:23:44 AM »

 Hello Mach3 users and team,

 I'm using Mach3 from some time already and it fits currently my needs with Mach3 2010 Screenset.


 I'd like to do something which looks super easy but I cannot find how to do it !

 Here is my problem:

 When a tool change is requested, the spindle stops automatically.

 I have to be close enough from CNC and check there is no noise anymore. In most case, I can hear it
 but sometimes, I don't, and I waste time !

 I'd like to patch a VB script (.m1s) so, when the spindle stop (Tool change, or end of program)
 a DOS script would be called that contains a script that would send a message to my phone through Telegram.

 The Telegram feature is OK, I use it widely on my home automation system, which runs under linux.

 I am much more confortable in Linux than Windows, and I must admit that I'm not able to find a clear solution
 for my need, even after hour of VB script hacking.

 Which macro should I modify and how, just to call a script "notify.bat" for example ?

 Here is the info for Telegram messaging in case someone needs it.

 https://stackoverflow.com/questions/68213124/telegram-example-of-how-to-use-curl-for-windows-10-to-message-myself-with-a-bot


 Thank you for your help !

Offline Graham Waterworth

*
  • *
  •  2,783 2,783
  • Yorkshire Dales, England
Re: Call a DOS batch script (.bat) from a macro
« Reply #1 on: June 12, 2024, 07:36:03 AM »
Have you tried this, put this line in your M6Start.m1s or create your own M code.

RunScript(Filepath)
Without engineers the world stops
Re: Call a DOS batch script (.bat) from a macro
« Reply #2 on: June 12, 2024, 07:49:16 AM »
 Honestly, I didn't !

 I know nothing about VBA script.

 It's far away from embedded C/C++ where I'm much more talented !

 From your point of view:

 If I follow those steps:

 Create: m123.m1s

      - m should be m or M ?
      - Where should I store this script ?

 which contains RunScript("notify.bat")

      - Should the path be absolute, or if notify.bat is in the same directory like m123.m1s, then it's OK ?

     - I think I must also update my Mach3 post processor in my CAD SW to automaticaly add m123 where needed, right ?


 Thank you for your help, I 'll try this tonight.

Offline TPS

*
  •  2,592 2,592
Re: Call a DOS batch script (.bat) from a macro
« Reply #3 on: June 15, 2024, 06:56:16 AM »
if you want to excecute your dos script every time the spindle stops, you can put it in

-M5.m1s    M or m does not matter
-you should find this file already in C:\Mach3\macros\{your profile name}
-you can edit this file with any text editor, only important thing is make sure that the last
 line has a CR at the end (Without sometimes crazy things are happening, but only sometimes)
-use the absolute path RunScript("C:\{absolute path}\notify.bat") or put the bat file in same folder
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.