如何确定是否安装了 VSTO 2010 Runtime?

发布于 2024-09-01 10:14:25 字数 521 浏览 3 评论 0原文

只需使用产品代码 {388E4B09-3E71-4649-8921-F44A3A2954A7} 调用 MsiGetProductInfo() 即可轻松检查是否安装了 VSTO 2005 SE,如 MSDN 中列出

VSTO 2010/4.0 运行时的产品代码是什么?或者有没有更好的方法来确定它是否已经安装?这是我们的安装过程。

另外,我试图找出相同的 Windows 映像组件

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

淑女气质 2024-09-08 10:14:25

不幸的是,到目前为止,这里的答案并没有完全涵盖所有基础。

产品代码

这似乎并不可靠 - 我们正在寻找最低版本,而不是特定版本。虽然理论上产品代码应该只针对主要版本增量进行更改,但我的计算机上的 VSTO 版本 - 10.0.40303 - 的产品代码为 {A0FE0292-D3BE-3447-80F2-72E032A54875}。这表明微软不一定能让它们保持稳定,所以我建议这不是一个好的选择。

文件版本

另一种选择可能是检查 VSTO 程序集本身是否存在/版本,通常位于 %PROGRAM FILES%\Common Files\Microsoft Shared\VSTO\10.0 中。不过我想说这个目录是不能保证的 - 实际目录似乎是在注册表中指定的,但显然这个解决方案现在并不比直接从注册表中获取版本更好......

注册表

因此,通过注册表可能是唯一的选择。

遗憾的是,VSTO 运行时版本可能出现在 4 个注册表位置中的任意一个中:

  • HKLM\SOFTWARE\Microsoft\VSTO Runtime Setup\v4(32 位,从 Office 2010 安装中安装的 VSTO)
  • HKLM \SOFTWARE\Microsoft\VSTO Runtime Setup\v4R(32 位,从可再发行组件安装的 VSTO)
  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO Runtime Setup\v4(64 位,VSTO从 Office 2010 安装安装)
  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO Runtime Setup\v4R(64 位,从可再发行组件安装的 VSTO)

注意:我没有明确的来源 - 我我正在拼凑一些信息,例如 Wouter van Vugt 的这篇博文这个答案。可能还有更多的事情要做。

此外,可能还有最低版本要求,但我怀疑实际上这只会影响运行 Office 2010 预发行版本的用户:

Visual Studio 2010 Office 运行时工具还附带
Microsoft Office 2010。但是在 Office 2010 RTM 时代,
Office 运行时仅支持面向以下目标的 Office 解决方案
.NET框架3.5。如果您的解决方案面向 .NET Framework 3.5,
如果安装了 Office 2010 或 Visual Studio,它就可以运行
已安装 2010 Office Runtime 可再发行工具工具。如果你的
Office 解决方案以 .NET Framework 4 为目标,您必须重新分发
Visual Studio 2010 Tools for Office Runtime(引用)。

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).

坏尐絯 2024-09-08 10:14:25

最简单的方法是检查注册表。

HKLM\Microsoft\vsto 运行时设置\v4\Install

HKLM\Microsoft\vsto 运行时设置\v4R\VSTORFeature_CLR40(适用于 4.0 Office 扩展)

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)

忆梦 2024-09-08 10:14:25

最安全、最干净的方法仍然是检查产品代码,如下:

对于 VSTO 2010 x86,版本 10.0.31124: {41A01180-D9FD-3428-9FD6-749F4C637CBF}

对于 VSTO 2010 x64,版本10.0.31124:{C3600AE6-93A0-3DB7-B7AA-45BD58F133B5}

我通过使用 7-Zip 提取以下包的内容并使用 Orca 分析 MSI 来获取它们:

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

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

二货你真萌 2024-09-08 10:14:25

它们的密钥因您要安装的操作系统而异。我煞费苦心地在 x86 和 x64 中安装了独立的 vsto 和 Office 2010 和 2013 .exe。
为了使用注册表检查是否安装了 vsto,您需要验证以下项是否存在:

对于 x64:

  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO 运行时安装程序\v4 ->安装

  • HKLM\SOFTWARE\Wow6432Node\Microsoft\VSTO 运行时安装程序\v4 ->产品代码

对于 x86:

  • HKLM\SOFTWARE\Microsoft\VSTO 运行时设置 ->安装程序路径

编辑:我实际上最终做的是验证 v4 文件夹是否存在。

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.

贪恋 2024-09-08 10:14:25

在 SCCM 2012 中将 Vstor 部署为应用程序时,我需要一种方法来检测这一点。我使用以下 PowerShell 脚本从 WMI 检索信息。

如果版本为 10.0.50908,则会生成输出。如果检测脚本返回任何值,SCCM 就会认为检测成功。

$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"}

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"}
給妳壹絲溫柔 2024-09-08 10:14:25

这里是代码。
在公共方法中,我们确定 VSTO 是从 Office 还是 VSTO 运行时包安装的。
在私有方法中,检查版本是否等于或大于版本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;
    }

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;
    }

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文