简体   繁体   English

适用于所有用户的Install4j安装

[英]Install4j installation for all users

I am working on packaging Java 7 application for Windows using install4j. 我正在使用install4j为Windows打包Java 7应用程序。 In the installation i want to provide a choice to install the application for all users or just for the current user. 在安装中,我想提供一个选择,为所有用户或仅为当前用户安装该应用程序。

If by installing "for all users" you mean installing to the program files directory, then you can do that by setting the installation directory as runtime. 如果通过安装“针对所有用户”是指安装到程序文件目录,则可以通过将安装目录设置为运行时来进行安装。

Add a custom form where you ask the user whether they want to to install it for all users or just the current user. 添加一个自定义表单,询问用户是要为所有用户还是仅为当前用户安装该表单。 To that form screen, add a "Run script" action that sets the installation directory via 在该表单屏幕上,添加一个“运行脚本”操作,该操作通过以下命令设置安装目录

context.setInstallationDirectory(...)

The program files directory is available from 程序文件目录可从以下位置获得

WinFileSystem.getProgramFilesDirectory()

and the home directory from 和主目录

System.getProperty("user.home")

If you want to install to the program files directory, you need elevated privileges. 如果要安装到程序文件目录,则需要提升的特权。 By default, install4j projects have a "Request privileges" action in the startup node of the installer. 默认情况下,install4j项目在安装程序的启动节点中具有“请求特权”操作。 Move that action before the above "Run script" action and set its condition expression so that it is only executed for the "all users" case. 将该动作移至上述“运行脚本”动作之前,并设置其条件表达式,以便仅针对“所有用户”情况执行该动作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM