The batch file I wrote above handles all of the OS types. I found that by using errorlevels on every OS check would sometimes lead to problems.

Once in a while I would get one of the systems that would read or set the errorlevel incorrectly.