我已经为 MyProgram 创建了一个安装程序,但它创建的卸载快捷方式留下了空文件夹

发布于 2024-09-03 21:48:13 字数 1412 浏览 6 评论 0原文

我使用 Visual Studio 安装程序(Visual Studio 安装项目)为 MyProgram 创建了一个安装程序。它称为“MyProgram Setup.msi”。它可以很好地安装程序,如果使用“添加/删除程序”控制面板卸载该程序,则所有内容都会按其应有的方式删除。

问题是我想在名为“Uninstall MyProgram”的程序快捷方式下添加“用户程序菜单”的快捷方式。我已尝试以 3 种不同的方式执行此操作,并且在所有 3 种方式中,如果使用该快捷方式卸载 MyProgram,则卸载将留下 2 个空文件夹(“...Program Files\MyCompany\”和“...Program Files\MyCompany\MyProgram\”)。

以下是我尝试创建卸载程序快捷方式的 3 种方法:

1) 批处理或脚本文件的快捷方式

卸载 MyProgram.bat:

@ECHO OFF
msiexec /uninstall {MyGUID}

卸载 MyProgram.vbs:

Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("START /B msiexec /uninstall {MyGUID}")
Set objShell = Nothing

2) 编辑 MSI使用 Orca.exe 文件

我找到了如何使用本指南执行此操作: http://www.codeproject.com/KB/install/MSIShortcuts.aspx

我将快捷方式条目添加到快捷方式表中。卸载成功,但使用此快捷方式时仍然留下 2 个空文件夹。

3) 从 MyProgram.exe 中的代码

我修改了 MyProgram.exe 以采用“/uninstall”命令行参数来运行“msiexec.exe /uninstall {MyGUID}”并自行退出。类似于此解决方案: http://www.codeproject.com/KB/install/DeployUninstall .aspx

这些尝试都没有创建可以卸载程序及其基本文件夹的快捷方式。我不想切换到其他安装程序产品,例如 Inno Setup、NSIS 或 WiX。

I have created an installer for MyProgram using the Visual Studio Installer (Visual Studio Setup Project). It is called "MyProgram Setup.msi". It installs the program fine and if it is uninstalled using the Add/Remove Programs control panel then everything gets removed as it should.

The problem is that I want to add a shortcut to the "User's Programs Menu" under the program shortcut called "Uninstall MyProgram". I have tried doing this in 3 different ways and in all 3 ways if MyProgram is uninstalled using that shortcut, the uninstall will leave behind 2 empty folders ("...Program Files\MyCompany\" and "...Program Files\MyCompany\MyProgram\").

Here are the 3 ways that I have tried to make an uninstaller shortcut:

1) A shortcut to a batch or script file

Uninstall MyProgram.bat:

@ECHO OFF
msiexec /uninstall {MyGUID}

Uninstall MyProgram.vbs:

Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("START /B msiexec /uninstall {MyGUID}")
Set objShell = Nothing

2) Editing the MSI file using Orca.exe

I found out how to do this using this guide: http://www.codeproject.com/KB/install/MSIShortcuts.aspx

I added the Shortcut Entry to the Shortcut table. Uninstalling worked but it still left behind the 2 empty folders when using this shortcut.

3) From code within MyProgram.exe

I modified MyProgram.exe to take a "/uninstall" command line parameter to run "msiexec.exe /uninstall {MyGUID}" and exit itself. Similar to this solution: http://www.codeproject.com/KB/install/DeployUninstall.aspx

None of these attempts created a shortcut which can uninstall the program as well as the program's base folders. I don't want to switch to some other installer product such as Inno Setup, NSIS, or WiX.

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

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

发布评论

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

评论(2

青春如此纠结 2024-09-10 21:48:13

如果出于某种原因手动运行 msiexec /x {MyGUID} 没有删除所有文件夹,则可能是您的设置或您在应用程序中执行的操作存在问题。

有关使用 WiX 创建卸载快捷方式的更多信息,请查看 这篇博文 介绍了相当多的细节。根据博客文章中显示的信息,您应该能够弄清楚如何坚​​持使用现有技术并使用您提到的 (2) 方法的一些变体。

If for whatever reason manually running msiexec /x {MyGUID} doesn't remove all folders, then it's an issue with your setup or something you're doing in your application.

For more information about creating an uninstall shortcut with WiX, check out this blog post which goes into quite a bit of detail. Based on the information shown in the blog post you should be able to work out how to stick with your existing technology and use some variation on the (2) method you mention.

假情假意假温柔 2024-09-10 21:48:13

看来这是 Visual Studio 安装程序中的一个错误。我决定改用 WiX 。它能够创建具有正确功能的卸载快捷方式。

It seems that this is a bug in the Visual Studio Installer. I have decided to use WiX instead. It is able to create the uninstall shortcut with correct functionality.

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