REG QUERY - SHELL - MSOFFICE

Hi,

I need check if an user has differents versions of MS Office installed. For this purpose, I have wrote this code that I use with shell tool:
`

dim s as new Shell
dim d, q as String

//Vars
q=“REG QUERY HKLM\Software\Microsoft\Office”

//Shell task
s.Execute(q)
d=s.ReadAll

//Get result
MsgBox d

`

After run the proccess I get this result that is good for my target:

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\11.0
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\12.0
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\15.0
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\8.0
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Common
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Delivery
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Excel
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\InfoPath
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\MS Project
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\OneNote
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\OpenXmlSDK
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Outlook
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\PowerPoint
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Word

But I need obtain the path directory where the app is installed. Someone know how can I do this …?

Thanks in advance for any suggestion.

Hi Elvis,

The paths to installed applications are located in the following area of the registry:

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\

Each application would have its own subdirectory. Excel would be excel.exe and Word would be WinWord.exe. Each subdirectory would have this information in the Path name. An example for the path for Excel would be:

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\excel.exe\\Path

On my machine the registry key REG_SZ for path is:

C:\\Program Files (x86)\\Microsoft Office\\Root\\Office16\\

and you would need to add the executable filename at the end, which is EXCEL.EXE.

From windows shell i remember is this c:\\where file.exe
If you want to find all copies of a file in a directory tree, you can use

WHERE /R <Top Level Directory> <search text>

Hi Eugene, Loanis,

Thanks for your reply. Just a little detail with this.

01- The target of the app is obtain all versions of MS Office that user has installed. It’s possible find on some PC, versions of MSO2016, MSO 2013, etc.

I know that in order to not use the option to read the Regedit, I can do that directly in Xojo with:
`
Dim xls as new ExcelApplication
dim sPath as String

//Vars
sPath=xls.Path
MsgBox sPath
`

But this option do not solve the problem if the PC user has more of one MSO version.

02- If I get the path for every MSO version, I will need explore each directory to get all .EXEs ("EXCEL.EXE,“POWERPNT.EXE”,“WINWORD.EXE”,etc) and show to the user the the .EXE and the version he want use.

Thinking in that, that’s the reason why I’m using the option to read the regedit.

Eugene, with “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe\Path”, I can obtain the path for all versions…? Perhaps do you have a little example …? Have you had some time this case …?

Thanks

Hi Elvis,

I believe this path will only give you the current installed version. Each version of office has a different version number, and Office 2016 is version 16. The path to check which versions have been installed is in the registry path:

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\

In the above directory, check for the folder version. and on my machine I only have one version of Office 2016 installed which has a folder with the name 16.0. If there are two versions then there would be two numbers, such as 16.0 for 2016, and 15.0 for 2015. A table with a list of each version number for Microsoft Office and the year that it was released is available on the wikipedia page for Microsoft Office.

Sorry, I haven’t worked out an example yet.

Hi Elvis,

Registry Redistributable Search

Here is a link to a Xojo example that I put together with searches a RegistryItem with Xojo code. Maybe this will help?

Hi Eugene,

Thanks for the thread. Taking the example, I have made some changes just to test. I obtain a list with data for “Office”. But now, I’m trying to obtain the path where the application is installed according to the list.

`

Dim reg As New RegistryItem(“HKEY_LOCAL_MACHINE\Software\Microsoft\Office”)
Dim Folders() As String
Dim Path as String
Dim TryReg as RegistryItem

//Check the subfolders
For i as Integer = 0 to reg.FolderCount-1

Folders.Append reg.Item(i).Path
TryReg = new Registryitem(Folders(i))

//Check general data
For j as integer = 0 to TryReg.KeyCount-1
  
  //Available data
  Listbox1.AddRow
  Listbox1.Cell(Listbox1.ListCount-1,0)= Cstr(TryReg.Value(j))
  Listbox1.Cell(Listbox1.ListCount-1,1)=   TryReg.Path
  
Next

Next

`

I can’t believe it’s so complicated to obtain this information. Unfortunatelly, the command just offers options for DisplayName, DisplayVersion, Publisher and InstallDate, but not more.

I will continue my search.

From the command prompt and where command you get the filename and the directory=(the path).
If you write c:\\where /r c:\\program files winword.exe the top directory is (program Files) and the /R flag is recursive,is looking every subdirectory.
With Eugene solution and the shell you combine them and get the results?

Hi Loannis,

Thanks for your suggestion. I will do that as part of several test that I’m doing.