One possible way to obtain the current version of Windows and the version of Microsoft Office is to query the registry entries using the command line.
To get the version of Windows using the registry, use the following command:
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v "ProductName"
This will produce a result that can be analyzed to get the current version / window name.
To get the current version of the office, use:
reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer"
The output of this command gives the Office version in numerical format, such as 14, 15, etc.
Parse the output to get the version number and match the list of existing versions of Microsoft Office to get the name of the installed version:
Office 97 - 7.0 Office 98 - 8.0 Office 2000 - 9.0 Office XP - 10.0 Office 2003 - 11.0 Office 2007 - 12.0 Office 2010 - 14.0 Office 2013 - 15.0 Office 2016 - 16.0
Hope this helps!
source share