I wanted to know the best way to upgrade from Splunk 7342 running on windows server 2012r2 to windows server 2016 or 2019 running the latest version of splunk for windows?
First, see https://community.splunk.com/t5/Getting-Data-In/What-are-the-pain-points-with-deploying-your-Splunk-...
Are you planning an in-place upgrade or will the new OS be on different hardware?
What is the current architecture (standalone Splunk, indexer cluster, etc.)?
Start by reading the Release Notes for all of the versions since 126.96.36.199. They will explain any steps you must take to upgrade to (or beyond) that version.
Install and run the Splunk Upgrade Readiness app to identify any Python 3 incompatibilities in your environment.