문제

When installing an application (packed with install4j) onto a computer that already has it installed with admin and then with other user rights, the installer will produce another icon on the desktop resulting in 2 or more application icons.

To reproduce this:

  1. Install the application as an admin user on windows
  2. Log into another user account that is not an admin. (A normal user account)
  3. Install application once again, and after the client is finished installing it will produce another icon on the desktop

How can I avoid this behavior?

도움이 되었습니까?

해결책

There are two different desktop folders involved, the public one and the user specific one. If the "Create for all users" property of the "Add a desktop link" action is selected, the action will try to create the link in the public folder, but that usually requires admin privileges. If you don't have admin privileges, you could check if such a file already exists in the public folder. The condition expression of the action could be set to something like:

if (!Util.hasFullAdminRights()) {
    File publicLink = new File(WinFileSystem.getSpecialFolder(
        SpecialFolder.DESKTOP, true), "launcher name.lnk");
    return !publicLink.exists();
} else {
    return true;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top