'Batch building the same code multiple times with different values for a variable in Visual Studio

I need to build my code with a variable MyVar. I need to build it eg. 10 times but for each time, MyVar would be different, eg.

First build: static unsigned char MyVar[] = "ABC";

Second build: static unsigned char MyVar[] = "XYZ";

Is there an option to do this in a batch style? Eg. the command line? I just don't want to change MyVar manually, press "build", rename the built file etc.

Thanks a lot

PS: I'm not a professional coder, this could be bad practice. At the same time I'd just like to get the job done and don't want to change the code too much.

PPS: Already looked into several things (property sheets, custom macros, per-/post build actions, environment variables) but didn't find anything suitable.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source