简体   繁体   English

卸载 MS Office 应用程序级 VSTO 加载项

[英]Uninstalling an MS Office Application-Level VSTO Add-In

I am working on deploying my first Visual Studio Tools for Office (VSTO) add-in using VSTO 4.我正在使用 VSTO 4 部署我的第一个 Visual Studio Tools for Office (VSTO) 加载项。

There are some different options for installing the Add-In registry entries.有一些不同的选项可用于安装加载项注册表项。 It can be per user under HKEY_CURRENT_USER or per machine HKEY_LOCAL_MACHINE.它可以是 HKEY_CURRENT_USER 下的每个用户或每个机器 HKEY_LOCAL_MACHINE。 A number of my users are running under Citrix or Terminal Services.我的一些用户在 Citrix 或终端服务下运行。 I am in a situation where an administrator will be running my install on the server as the users do not have the correct rights.我的情况是管理员将在服务器上运行我的安装,因为用户没有正确的权限。 In addition, my users are only a small percentage of the users on these servers.另外,我的用户只是这些服务器上的一小部分用户。

For those reasons I was planning on building a small utility that would ship with the Add-In.出于这些原因,我计划构建一个随插件一起提供的小型实用程序。 The utility would create the correct Per User registry keys to enable the add-in.该实用程序将创建正确的每用户注册表项以启用加载项。 The administrator would install the add-in dll and my utility to c:\program files*.管理员会将插件 dll 和我的实用程序安装到 c:\program files*。 Then the users who actually needed the add-in would be instructed to run the utility one time and click on the "Enable" button.然后将指示实际需要加载项的用户运行该实用程序一次并单击“启用”按钮。

The problem I am stuck with now is how to uninstall the add-in.我现在遇到的问题是如何卸载加载项。 My un-installer (run again by an administrator) can deal with everything that it created but does not have a way to remove the Per User registry keys.我的卸载程序(由管理员再次运行)可以处理它创建的所有内容,但无法删除 Per User 注册表项。

I was hoping this would be a problem and that Word would just ignore the missing Add-in on the next startup.我希望这会是一个问题,并且 Word 会在下次启动时忽略丢失的加载项。

That does not work - Word reports an error trying to "install" the customization on the next run.这不起作用 - Word 报告在下次运行时尝试“安装”自定义项时出错。

"Installing Office customization" There was an error during installation. “安装 Office 自定义” 安装过程中出错。 Downloading file file://xxx/xxx.vsto did not succeed.下载文件 file://xxx/xxx.vsto 没有成功。

I am including "|vstolocal" at the end of the registry entry per the Registry Entries for Application-Level Add-Ins msdn article .根据应用程序级加载项的注册表项 msdn 文章,我在注册表项的末尾添加了“|vstolocal”。

Is there anyway to stop Word from trying to load the add-in if the file does not exist?如果文件不存在,是否有阻止 Word 尝试加载加载项的方法?
or或者
Is there a way for an uninstaller to clean up Per User registry entries on uninstall for a user other than the one running the uninstall?卸载程序是否有办法在卸载时为运行卸载的用户以外的用户清理 Per User 注册表项?

I am doing my testing on a Windows 7 machine with Office 2007. I am using VSTO 4 targeting the.Net 4 Framework.我正在使用 Office 2007 在 Windows 7 机器上进行测试。我正在使用针对 .Net 4 框架的 VSTO 4。

About your two questions关于你的两个问题

Is there anyway to stop Word from trying to load the add-in if the file does not exist?如果文件不存在,是否有阻止 Word 尝试加载加载项的方法?

Not that I'm aware of, but, I just tried moving off the DLL's the my reg entries point to for one of my addin's and I got no message (if I go into Word's options COM ADDins area, i can see the addin is not loaded, which would be correct).不是我知道的,但是,我只是尝试将 DLL 的我的 reg 条目指向我的插件之一,我没有收到任何消息(如果我 go 进入 Word 的选项 COM ADDins 区域,我可以看到插件是未加载,这是正确的)。

Is there a way for an uninstaller to clean up Per User registry entries on uninstall for a user other than the one running the uninstall?卸载程序是否有办法在卸载时为运行卸载的用户以外的用户清理 Per User 注册表项?

Nope, I'm virtually positive there is no way to do this.不,我几乎肯定没有办法做到这一点。 It'd require rights to EVERY user's Profile folders.它需要每个用户的个人资料文件夹的权限。

HOWEVER, you can create these weird keys under the Office reg tree, that essentially serve as "commands" for office apps to carry out when they load.但是,您可以在 Office reg 树下创建这些奇怪的键,这些键基本上用作 Office 应用程序在加载时执行的“命令”。

So on uninstall, you'd write the extra keys to the Office reg key that essentially says "remove these keys from the current HKCU hive when an office app loads".因此,在卸载时,您会将额外的密钥写入 Office reg 密钥,该密钥实质上是“在加载 Office 应用程序时从当前的 HKCU hive 中删除这些密钥”。

Here's an example Reg script I found that shows the weird keys, but I can't right off find any links that document exactly what they are:这是我发现的一个示例 Reg 脚本,它显示了奇怪的键,但我无法立即找到任何可以准确记录它们的链接:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\AllUsersTemplates]
"Count"=dword:00000001
"Order"=dword:00000008

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\AllUsersTemplates\Create\Software\Microsoft\Office\12.0\Common\General]
"SharedTemplates"=hex(2):-fill in your own Binary Value-

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\RemoveInstantSearchBar]
"Count"=dword:00000001
"Order"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\RemoveInstantSearchBar\Create\Software\Microsoft\Office\12.0\Outlook\Search]
"DisableDownloadSearchPrompt"=dword:00000001

<<<<< CreateFile >>>>>>>
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\FileCopy1]
"Count"=dword:00000001
"Order"=dword:00000008

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\FileCopy1\CreateFile\FileCopy1.potx]
"TargetFile"="[AppDataFolder]\\Microsoft\\Templates\\FileCopy1.potx"
"SourceFile"="C:\\Documents and Settings\\All Users\\Templates\\FileCopy1.potx"

If you look closely, you'll see under the \Office\ key, a "user settings{name}\Create\" key and then the rest of the key path replicates the path from Software\ on down under HKCU.如果仔细观察,您会在 \Office\ 键下看到一个“用户设置{name}\Create\”键,然后键路径的 rest 复制了 HKCU 下从 Software\ 开始的路径。

You can use the keywords CREATE or DELETE (to remove a key).您可以使用关键字 CREATE 或 DELETE(删除键)。

Notice the COUNT and ORDER values though.请注意 COUNT 和 ORDER 值。 Those are important and need to be set right.这些很重要,需要正确设置。

But again, i can't find the links off hand that document this.但同样,我无法找到记录此内容的链接。

You could use an Active Setup to uninstall your per-user VSTO add-in.您可以使用Active Setup来卸载每用户 VSTO 加载项。

If you're unfamiliar with Active Setup, this feature compares HKLM Installed Components subkeys to HKCU Installed Components subkeys and if a subkey is missing (or if found and the subkey Version value is greater) the StubPath value is executed and the HKLM Installed Components subkey is copied to HKCU Installed Components.如果您不熟悉 Active Setup,此功能会将 HKLM Installed Components 子项与 HKCU Installed Components 子项进行比较,如果缺少子项(或者如果找到并且子项版本值更大),则会执行 StubPath 值并使用 HKLM Installed Components 子项复制到 HKCU Installed Components。

Disclaimer: Active Setup is an undocumented, yet frequently used, Windows feature.免责声明: Active Setup 是一种未记录但经常使用的 Windows 功能。 Use at your own risk.使用风险自负。 Do not taunt Active Setup.不要嘲弄 Active Setup。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM