简体   繁体   中英

Install4j: How to create cross-platform desktop shortcut

I have an Install4J v7 project that creates Windows, Mac and Linux. I'd like to get it to add a desktop shortcut, too.

I gather I have to add the "Add a desktop link" action, and then fill in the "Target file" name.

Question: the "Target file" name will be different for each platform (eg, for Windows: myapp.bat ... for Mac/Linux: myapp.sh). I suspect there's an easy way, but I'm not seeing it.

Can anyone weigh in??

Thanks!

The "Add a desktop link" action automatically appends ".exe" to the configured target on Windows if the target file does not exist.

".sh" and ".bat" are not handled by default. For special requirements, use a "Set a variable" action where you return the desired file name based on the current platform, for example you can set its "Script" property to:

if (Util.isWindows()) {
    return "myfile.bat";
} else  {
    return "myfile.sh";
}

If its "Variable name" property is set to "myFileName", you can then set the "Target file" property of the "Add a desktop link" action to

${installer:myFileName}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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