【问题标题】:How to (silently) uninstall MySQL on 32 and 64 bit Windows如何(静默)在 32 位和 64 位 Windows 上卸载 MySQL
【发布时间】:2012-05-04 04:45:59
【问题描述】:

我们在当前版本的软件中使用 Install4J,并在安装过程中静默安装 MySQL 5.1。

对于我们软件的下一个版本,如果是升级的话,我想去掉MySQL 5.1,安装5.5。理想情况下,卸载应该静默进行,但不是硬性要求。我设法让它在 32 位 Windows XP 上运行,但不能在 64 位 Windows 7 上运行。这是我目前所拥有的:

String[] uninstallKeys = WinRegistry.getSubKeyNames(RegistryRoot.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
for( String uninstallKey : uninstallKeys )
{
  Object displayVersion = WinRegistry.getValue(RegistryRoot.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uninstallKey, "DisplayVersion" );
  Object displayName = WinRegistry.getValue(RegistryRoot.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uninstallKey, "DisplayName" );
  if( displayVersion != null && displayVersion.toString().equals(installedMysqlVersion)
                  && displayName != null && displayName.toString().startsWith("MySQL Server") )
  {
    Util.logInfo( null, "Found match, uninstall key: " + uninstallKey );
    context.setVariable( "mysqlUninstallKey", uninstallKey );
    break;
 }
}

这会将 MySQL Server 5.1 的产品代码放入 mysqlUninstallKey 变量中。在这一步之后,我有一个具有以下设置的“运行可执行文件或批处理文件”步骤:

  • 可执行文件:msiexec.exe
  • 工作目录:${installer:sys.system32Dir}
  • 参数:/I{installer:mysqlUninstallKey}

这将(在 32 位 Windows XP 上)运行 MySQL 服务器的安装程序,然后用户必须手动选择“删除”。

在 64 位 Windows 7 上,它只显示一个对话框,显示所有命令行标志及其解释,因此 msiexec.exe 正在启动,但我传递给它的参数无法识别。

知道可能出了什么问题吗?或者也许我这样做完全错误并且有更好的方法?

我使用 Install4j 4.2.8。

【问题讨论】:

  • 要删除旧版本,请使用msiexec.exe /qn /x {target product code}

标签: mysql uninstallation install4j


【解决方案1】:

感谢@marcus-adams 的评论,我明白了。您需要在 install4j 的“运行可执行文件或批处理文件”操作中使用“/qn”、“/x”和“{installer:mysqlUninstallKey}”作为单独的参数。如果将 1 个参数与空格一起使用,则它不起作用。有了它,它适用于 32 位和 64 位。

【讨论】:

    猜你喜欢
    • 2012-10-26
    • 2021-11-16
    • 2011-09-02
    • 2015-03-07
    • 1970-01-01
    • 2018-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多