如何(静默)在32位和64位Windows上卸载MySQL [英] How to (silently) uninstall MySQL on 32 and 64 bit Windows

查看:147
本文介绍了如何(静默)在32位和64位Windows上卸载MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将Install4J用于我们当前的软件版本,并在安装过程中以静默方式安装MySQL 5.1.

We are using Install4J for our current version of our software and install MySQL 5.1 silently during the installation.

对于我们软件的下一版本,如果是升级,我想删除MySQL 5.1并安装5.5.理想情况下,卸载应该静默进行,但不是硬性要求.我设法使其在32位Windows XP上运行,但在64位Windows 7上却无法运行.

For the next version of our software, if it is an upgrade, I want to remove MySQL 5.1 and install 5.5. Ideally, the uninstall should go silently, but not a hard requirement. I managed to get it working on 32-bit Windows XP, but not on 64-bit Windows 7. This is what I have so far:

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变量中.完成此步骤后,我将执行运行可执行文件或批处理文件"步骤,并进行以下设置:

This will put the product code of MySQL Server 5.1 in the mysqlUninstallKey variable. After this step, I have an 'Run executable or batch file' step with the following settings:

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

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

This will (on 32-bit Windows XP) run the installer of MySQL server and then the user has to select 'remove' manually.

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

On 64-bit Windows 7, it just shows a dialog showing all the command line flags and their explanation, so msiexec.exe is being started, but the argument I pass into it is not recognized.

任何主意可能有什么问题吗?还是我做错了这,而有更好的方法吗?

Any idea what might be wrong ? Or maybe I am doing this totally wrong and there is a better way?

我使用Install4j 4.2.8.

I use Install4j 4.2.8.

推荐答案

由于@ marcus-adams的评论,我知道了.您需要在install4j的运行可执行文件或批处理文件"操作中将"/qn","/x"和"{installer:mysqlUninstallKey}"用作单独的参数.如果您将1个参数与空格一起使用,则它将不起作用.有了它,它就可以在32位和64位上运行.

Thanks to the comment of @marcus-adams, I figured it out. You need to use '/qn', '/x' and '{installer:mysqlUninstallKey}' as separate arguments in the 'Run executable or batch file' action of install4j. If you use 1 argument with spaces, it does not work. With this it works on 32-bit and 64-bit.

这篇关于如何(静默)在32位和64位Windows上卸载MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆