Hi
What i would do is to changed 1 script in to two and install your MS 2008 R2 separated
First i would try your Script in a "Virtual-box" and correct 3 problems i see in Script ...1st... don't repeat command line's; this confuse your UEFI / CMD … 2nd you have no "EXE" to executed? 3rd *.bat need to be a lot longer.
While in VM do the Partition, first, then OS
See if it install MS Os arch ? if so; you damn good at code-writing.
Second thought, You using VS 2015-2017 pro/? you need to add MS Visual Studio coding with it, me i only know: C and C++, DOS 7, Java, COBOL, Rockwell I/O coding Old school robotic. No i can't built u a maid :-( but a GPS lawnmower cut grass, hell yes! Than go Walmart get the Robotic Vacuum Cleaner 200-600 dollar. You have a Clean yards, and clean carpet.
Sorry i can't help you there on "Coding” i was looking for my MS Server 2000/2003 OS to run a de-script to convert to Notepad++ I still looking? Must be In storage. But now i don't have 599-1500 dollar to learn VS or get the software. My Server MS 2000/2003, 8 trays 3.5 100-160 GB/ea pr 32 bits, a lot stuff/software's/games, 4 gb ram with 16 gb PCI-HHD 8 I/O control-or, plus? Top it off 1 GB MHz processor, Old as s***. 1995-2001 used. But still work. Sorry i shouldn't help you out. Well best of luck in coding. WG