【发布时间】: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