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

发布于 2024-11-04 19:53:39 字数 977 浏览 3 评论 0原文

我正在使用 VSTO 4 部署我的第一个 Visual Studio Tools for Office (VSTO) 加载项。

安装加载项注册表项有一些不同的选项。它可以是 HKEY_CURRENT_USER 下的每个用户或 HKEY_LOCAL_MACHINE 下的每个计算机。我的许多用户都在 Citrix 或终端服务下运行。我所处的情况是管理员将在服务器上运行我的安装,因为用户没有正确的权限。另外,我的用户只占这些服务器上用户的一小部分。

出于这些原因,我计划构建一个与加载项一起提供的小型实用程序。该实用程序将创建正确的每用户注册表项以启用加载项。管理员会将加载项 dll 和我的实用程序安装到 c:\program files*。然后,实际需要该加载项的用户将被指示运行该实用程序一次并单击“启用”按钮。

我现在遇到的问题是如何卸载该加载项。我的卸载程序(由管理员再次运行)可以处理它创建的所有内容,但无法删除每用户注册表项。

我希望这会成为一个问题,并且 Word 会在下次启动时忽略丢失的加载项。

这不起作用 - Word 报告在下次运行时尝试“安装”自定义时出错。

“安装 Office 自定义” 期间出现错误 安装。下载文件 file://xxx/xxx.vsto 未成功。

我根据注册表项在注册表项末尾添加“|vstolocal”应用程序级加载项 msdn 文章

如果文件不存在,是否可以阻止 Word 尝试加载加载项?

有没有办法让卸载程序在卸载时为运行卸载程序的用户以外的用户清理每用户注册表项?

我正在一台装有 Office 2007 的 Windows 7 计算机上进行测试。使用针对 .Net 4 Framework 的 VSTO 4。

I am working on deploying my first Visual Studio Tools for Office (VSTO) add-in using VSTO 4.

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. A number of my users are running under Citrix or Terminal Services. 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*. 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.

I was hoping this would be a problem and that Word would just ignore the missing Add-in on the next startup.

That does not work - Word reports an error trying to "install" the customization on the next run.

"Installing Office customization"
There was an error during
installation. Downloading file
file://xxx/xxx.vsto did not succeed.

I am including "|vstolocal" at the end of the registry entry per the Registry Entries for Application-Level Add-Ins msdn article.

Is there anyway to stop Word from trying to load the add-in if the file does not exist?
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?

I am doing my testing on a Windows 7 machine with Office 2007. I am using VSTO 4 targeting the .Net 4 Framework.

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

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

发布评论

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

评论(2

伤痕我心 2024-11-11 19:53:39

关于你的两个问题

是否有办法阻止 Word
尝试加载加载项,如果该文件
不存在?

我不知道,但是,我只是尝试移走我的插件之一的注册表条目指向的 DLL,但我没有收到任何消息(如果我进入 Word 的选项 COM ADDins 区域,我可以看到该插件是未加载,这是正确的)。

有没有办法让卸载程序
清理每用户注册表项
为除以下用户以外的用户卸载
运行卸载程序吗?

不,我几乎肯定没有办法做到这一点。它需要每个用户的个人资料文件夹的权限。

但是,您可以在 Office 注册表树下创建这些奇怪的键,这些键本质上充当 Office 应用程序在加载时执行的“命令”。

因此,在卸载时,您会将额外的密钥写入 Office 注册表密钥,其实质上是“在加载 Office 应用程序时从当前 HKCU 配置单元中删除这些密钥”。

这是我发现的一个示例 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"

如果仔细观察,您会在 \Office\ 键下看到一个“用户设置” {name}\Create\" 键,然后键路径的其余部分复制 HKCU 下 Software\ 的路径。

您可以使用关键字 CREATE 或 DELETE(删除密钥)。

但请注意 COUNT 和 ORDER 值。这些都很重要,需要正确设置。

但同样,我无法立即找到记录此内容的链接。

About your two questions

Is there anyway to stop Word from
trying to load the add-in if the file
does not exist?

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

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?

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.

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

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:

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.

You can use the keywords CREATE or DELETE (to remove a key).

Notice the COUNT and ORDER values though. Those are important and need to be set right.

But again, i can't find the links off hand that document this.

顾北清歌寒 2024-11-11 19:53:39

您可以使用活动安装来卸载每用户 VSTO 加载项。

如果您不熟悉 Active Setup,此功能会将 HKLM Installed Components 子项与 HKCU Installed Components 子项进行比较,如果子项丢失(或者找到并且子项 Version 值更大),则执行 StubPath 值并查看 HKLM Installed Components 子项复制到 HKCU 安装组件。

免责声明: Active Setup 是一项未记录但经常使用的 Windows 功能。使用风险自负。不要嘲笑 Active Setup。

You could use an Active Setup to uninstall your per-user VSTO add-in.

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.

Disclaimer: Active Setup is an undocumented, yet frequently used, Windows feature. Use at your own risk. Do not taunt Active Setup.

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