我想设置某些版本验证以防止最终用户在较新版本上安装旧版本。防爆。防止安装版本3时安装版本1。做这个的最好方式是什么?防止在较新版本上安装较旧版本
1
A
回答
0
您可以将“运行脚本”操作添加到安装程序的“启动”节点,以验证已安装的版本。
下面的代码片段演示了如何验证对较新版本,如果他们是简单的整数:
// The value returned by context.getInstallationDirectory() will be the last
// installation directory if the user has already installed the application
ApplicationRegistry.ApplicationInfo applicationInfo =
ApplicationRegistry.getApplicationInfoByDir(context.getInstallationDirectory());
if (applicationInfo == null) {
// The application has never been installed before
return true;
}
if (Integer.parseInt(applicationInfo.getVersion()) >
Integer.parseInt(context.getVersion())) {
Util.showErrorMessage("A more recent version has already been" +
" installed in this directory");
// By returning "false", the action will fail and the installer will quit.
// Note that you have to set the "Failure strategy" property of your
// "Run script" action to "Quit on error", otherwise the installer will continue.
return false;
} else {
return true;
}
+0
谢谢!版本更复杂,例如10.6.5。我需要什么改变?我得到一个java.lang.NumberFormatException:原样。 –
+0
它不在API中,但可以使用内部方法'com.install4j.runtime.util.VersionCheck.checkCompatible(version1,version2)',如果'version1'低于'version2',它将返回true。 –
相关问题
- 1. 如何让msi安装程序在较新的版本上安装旧版本?
- 2. 如何安装较旧版本的python
- 3. 安装较旧版本的gdb
- 4. 如何在较新版本上安装旧版本的UWP应用程序?
- 5. 使用较旧版本的MFC和较新版本的Visual Studio
- 6. Redmine +将较新的升级版本与较旧的升级版本合并(较旧的版本有变化)
- 7. 安装较新版本的libpng
- 8. 如何在AWS(Ubuntu)上安装较旧版本的Firefox?
- 9. 如何在CentOS上安装较旧的R版本
- 10. 使用旧版本numpy的,甚至有一个较新的版本中安装
- 11. 在旧版本上安装新版本的部署项目
- 12. 如果在Windows安装了较旧版本的软件,如何停止安装?
- 13. 旧版Ruby版本在安装最新版本之后显示
- 14. Maven的:版本:更新父随后安装安装旧版本
- 15. 如何在Mac OS上安装较新版本的Make?
- 16. 防止低版本的安装在高版本
- 17. 在较新版本的Ruby上运行旧的Ruby版本化应用程序
- 18. 在母版页中使用较新版本的jquery ui以及旧版本
- 19. 安装旧版本的firefox
- 20. 安装旧版本的Cygwin
- 21. 如何针对较旧版本的库配置/制作/安装?
- 22. 使用较旧的Python版本安装numpy RPM
- 23. 如何安装phpMyAdmin维护较旧版本的php? Linux Fedora 14
- 24. 如何安装或切换到较旧版本的GNU并行?
- 25. 源文件安全版将旧版本与当前版本进行比较
- 26. 安装.NET:覆盖旧版本与新
- 27. 将安装新版本的Python与旧版本冲突
- 28. 版本比较
- 29. 将Delphi XE 6 Android应用程序安装在较旧版本的Android OS上。
- 30. 防止BlackBerry应用程序安装在较旧的设备上
Install4j v5.1.15 –