You can run scripts in campaign battles. It simply isn't advised because you're powerless to know which units you're giving the labels to unlike in a historical battle where you define them.
You should be able to run a command when the battle scroll appears via the following:
Code:
monitor_event ScrollOpened ScrollOpened prebattle_scroll
select_element prebattle_withdraw_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
Theoretically that would monitor when the prebattle scroll is opened, and automatically withdraw. Similar buttons on that scroll are:
prebattle_autoresolve_button
prebattle_withdraw_button
I haven't done any scripts with those commands as of yet since haven't needed to, but it should work. Keep in mind that the event "ScrollOpened" only exports the triggers needed to identify it with the "ScrollOpened" condition, so you can't go adding a bunch of trigger-requiring conditions to lower down the circumstances. You can try using the I_ conditions but it's unclear exactly what it will be checking for with some of them, so it might go firing when unintended.