Wait, you install the old Windows version, then the upgrade, and then reformat? That doesn't sound right to me...
For Windows 7, if you have machine with empty disk, then you start installation of upgrade version, but do not provide product key and uncheck 'Activate' checkbox. This will install Windows in trial mode. Then, start upgrade setup again and let it 'upgrade' OS... After that, you have activated Windows on the machine.
For Windows 8, I am not sure if process of double installation will work.