13

It was easy to check if VSTO 2005 SE was installed by just calling MsiGetProductInfo() with the product code {388E4B09-3E71-4649-8921-F44A3A2954A7}, as listed in MSDN.

What is the product code for the VSTO 2010/4.0 runtime? Or is there a better way to determine if it's already installed? This is for our installation process.

Also, I am trying to figure out the same for Windows Imaging Component.

6 Answers 6

20

Unfortunately the answers here so far do not quite cover all the bases.

Product Code

This does not appear to be reliable - we're looking for a minimum version, not a specific version. Though the product code is in theory only supposed to change for major version increments, the version of VSTO on my machine - 10.0.40303 - has a product code of {A0FE0292-D3BE-3447-80F2-72E032A54875}. This suggests that Microsoft isn't necessarily keeping them stable, so I'd suggest this is not a good option.

File version

Another option may be to check for the presence / version of the VSTO assemblies themselves, which may typically be in %PROGRAM FILES%\Common Files\Microsoft Shared\VSTO\10.0. However I'd say this directory is not guaranteed - the actual directory appears to be specified in the registry, but obviously this solution is now no better than just getting the version from the registry directly...

Registry

So going by the registry is probably the only option left.

Unfortunately, the VSTO runtime version can appear in any one of 4 registry locations:

  • HKLM\SOFTWARE\Microsoft\VSTO Runtime Setup\v4 (32-bit, VSTO installed from Office 2010 installation)
  • HKLM\SOFTWARE\Microsoft\VSTO Runtime Setup\v4R (32-bit, VSTO installed from redistributable)
  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO Runtime Setup\v4 (64-bit, VSTO installed from Office 2010 installation)
  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO Runtime Setup\v4R (64-bit, VSTO installed from redistributable)

Note: I don't have a definitive source for this - I'm cobbling together bits of information from, for example, this blog post by Wouter van Vugt and this SO answer. There may be even more to it than that.

In addition, there may be minimum version requirements, though I suspect that in practice this is only going to affect people running pre-release versions of Office 2010:

The Visual Studio 2010 Tools for Office runtime also ships with Microsoft Office 2010. However at the time of Office 2010 RTM, the runtime with Office only supports Office solutions that target the .NET Framework 3.5. If your solution targets the .NET Framework 3.5, it can run either if Office 2010 is installed or if the Visual Studio 2010 Tools for Office Runtime redistributable is installed. If your Office solutions target the .NET Framework 4, you must redistribute the Visual Studio 2010 Tools for Office runtime (citation).

1
10

The easiest way is to check the registry.

HKLM\Microsoft\vsto runtime setup\v4\Install

HKLM\Microsoft\vsto runtime setup\v4R\VSTORFeature_CLR40 (this is for the 4.0 Office extensions)

3
  • 1
    The 2nd answer there (with VSTORFeature_CLR40) is probably more correct. I just had a scenario where the 1st registry entry (HKLM\Microsoft\vsto runtime setup\v4\Install) was found but my addins wouldn't load - and in fact VSTO wasn't installed.
    – PandaWood
    Nov 1, 2010 at 4:01
  • 2
    Can somebody elaborate on how one detects whether the installed VSTOR40 is x86 or x64? I have installed all combinations of the x86 and x64 runtimes, and the keys mentioned above are the only ones ever created - everything is under the WOW6432Node - meaning that there is no way to determine the 'bitness' of the installed runtime... (note that Office 2010 comes in both 32 and 64 bit flavors, and the .net processes that are spawned will be of the same bit-ness as the Office installation social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/…)
    – Adam
    Aug 8, 2011 at 22:26
  • I have discovered that VSTORFeature_ only exists in x64 installs. Please see my answer below for x86 installs. Mar 18, 2015 at 17:41
3

The safest and cleanest method is still checking the product codes, here they are:

For VSTO 2010 x86, version 10.0.31124: {41A01180-D9FD-3428-9FD6-749F4C637CBF}

For VSTO 2010 x64, version 10.0.31124: {C3600AE6-93A0-3DB7-B7AA-45BD58F133B5}

I got them by extraction the contents of the following packages with 7-Zip and analyzing the MSIs with Orca:

http://download.microsoft.com/download/F/3/9/F395E3C2-28A0-4F0D-9E20-FF4D1ADB08D8/vstor40_x86.exe

http://download.microsoft.com/download/F/3/9/F395E3C2-28A0-4F0D-9E20-FF4D1ADB08D8/vstor40_x64.exe

1

They keys vary by the OS you are installing to. I painstakingly installed the standalone vsto and office 2010 and 2013 .exe's in x86 and x64. In order to use the registry to check if vsto is installed, you need to verify the existence of the following keys:

for x64:

  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO Runtime Setup\v4 -> Install

  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO Runtime Setup\v4 -> ProductCode

for x86:

  • HKLM\SOFTWARE\Microsoft\VSTO Runtime Setup -> InstallerPath

Edit: What I actually ended up doing, was verify that the v4 folder exists.

0

I needed a way of detecting this when deploying Vstor as an application in SCCM 2012. I used the following PowerShell script to retrieve the info from WMI.

If the version is 10.0.50908, output is generated. SCCM considers detection to be successful if the detection script returns any value.

$VstorVersion = Get-WmiObject -Query "select ProductVersion from SMS_InstalledSoftware where ARPDisplayName = 'Microsoft Visual Studio 2010 Tools for Office Runtime (x64)'" -NameSpace "root\cimv2\sms"
if ($VstorVersion.ProductVersion -ge '10.0.50908') {Write-Host "Found"}
-1

Here code. In public method we determine is VSTO installed from Office or VSTO runtime package. In private method, check if version is equals or bigger than version VSTO2010

public static bool CheckVSTO2010 ( ) {
        string regFragment = IntPtr.Size == 8 ? "\\Wow6432Node\\" : "\\";
        string regVSTO = string.Format( @"SOFTWARE{0}Microsoft\VSTO Runtime Setup\", regFragment );
        return CheckVSTOVersion( regVSTO + "v4\\" ) || CheckVSTOVersion( regVSTO + "v4R\\" );
    }


    private static bool CheckVSTOVersion ( string keyPath ) {
        using (var key = Registry.LocalMachine.OpenSubKey( keyPath )) {
            //Not installed
            if (key == null) {
                return false;
            }
            var releaseKey = key.GetValue( "Version" );
            if (releaseKey != null && !string.IsNullOrEmpty( releaseKey.ToString() )) {
                var version = new Version( releaseKey.ToString() );
                return version.Major >= 10 && version.Build >= 40820;
            }
        }
        return false;
    }

1
  • 2
    Although the code is appreciated, it should always have an accompanying explanation. This doesn't have to be long, but it is expected.
    – peterh
    Jul 21, 2015 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.