Just like Windows does, everything in Wine is configured through the registry. Every single settings winecfg access can also be accessed through the registry using the regedit
utility, which can also be used in command line to either import a big .reg file or set individual keys on the command line itself.
All the used keys are in the Useful Registry Keys wiki page.
The easiest option in your case would be to export the configuration in a .reg file (right click on the keys you need, export) and then import then with wine regedit MyConfig.reg
in your auto-configure script. You can write the .reg manually as well if you want, it's just a .ini-style text file.
Edit: wanted to add that as a comment as it doesn't answer the question itself but suggest another way of doing it but I lack reputation here: I'd recommend to just create a full copy of your clean pre-installation prefix and just copy it back when you need to reset. You will avoid the whole script to reconfigure a clean prefix, and will also be much faster than reinstalling libraries through winetricks and running regedit as all its a disk only operation.