Unfortunately, that is kind of how programming works. You can't just write a method and expect it to magically get called, you have to call it from somewhere.
How do you want it to get triggered?
You need to describe your requirement in more detail. What is it you are actually trying to do? I've shown you how to create and add a button to a form at runtime. All you have to do is decide how and when you want this code to be run.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Let me make a wild guess. When you said "standalone CS file", you actually meant a completely separate application to the one that gets the new button.
Now you are throwing in other terms, plugin and batch. This all sounds a bit random to me and I think that if you can say precisely what it is that you want your programme to do then someone may be able to give you an answer.