I would challenge your command approach.
Generally, a closed, solid, polysurface will generate a good, clean, mesh but not always.
I would suggest first checking to be sure your object IS in fact closed, and solid. Then run the Mesh command and tweak the settings to optimized it.
Then check the mesh to be sure it is a “good” mesh and closed.
Then export the checked mesh to STL and you’d enjoy a 100% success rate.
Look for some kind of option to “suppress dialogue boxes” or something like that. I had the same problem a while back but suppressing those popups was as easy as putting in an -r or something like that.