问题描述
我已经使用Visual Studio安装程序(Visual Studio安装程序)为MyProgram创建了一个安装程序。它被称为MyProgram Setup.msi。它安装程序正常,如果使用添加/删除程序控制面板卸载,那么所有内容都应该被删除。
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.
问题是要在用户程序菜单下添加名为卸载MyProgram的程序快捷方式。我尝试以3种不同的方式执行此操作,并且在所有3种方式中,如果使用该快捷方式卸载MyProgram,则卸载将留下2个空文件夹(...程序Files \MyCompany\和... Program Files\MyCompany\MyProgram\)。
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\").
以下是我尝试过的3种方法做一个卸载程序快捷方式:
Here are the 3 ways that I have tried to make an uninstaller shortcut:
1)批处理或脚本文件的快捷方式
卸载MyProgram.bat:
Uninstall MyProgram.bat:
@ECHO OFF
msiexec /uninstall {MyGUID}
卸载MyProgram.vbs:
Uninstall MyProgram.vbs:
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("START /B msiexec /uninstall {MyGUID}")
Set objShell = Nothing
2)使用Orca.exe编辑MSI文件
我发现如何使用本指南:
I found out how to do this using this guide: http://www.codeproject.com/KB/install/MSIShortcuts.aspx
我将快捷方式条目添加到快捷方式表中。卸载工作,但使用此快捷方式仍然留下2个空文件夹。
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)从MyProgram.exe
我修改了MyProgram.exe以执行/ uninstall命令行参数,以运行msiexec.exe / uninstall {MyGUID}并退出本身。与此解决方案类似:
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
这些尝试都没有创建一个可以卸载程序的快捷方式以及程序的基本文件夹。我不想切换到其他安装程序产品,如Inno Setup,NSIS或WiX。
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.
推荐答案
这是Visual Studio安装程序中的一个错误。我决定使用。它能够创建具有正确功能的卸载快捷方式。
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.
这篇关于我已经为MyProgram安装了一个安装程序,但它创建的卸载快捷方式留下了空文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!