One possible way of obtaining the current Windows Version and Microsoft Office version is to query the system registry entries using command line.
To get the windows version using System registry , use the following command:
This will give an output which can be parsed to get the current windows version/name.
To get the current office version , use:
The output of this command gives the office version in number format such as 14, 15, etc.
Parse the output to get the version number and match against the list of existing Microsoft office versions to get the name of the version installed: