in a project, you usually need to call (open) third-party software, such as exe, bash script, dll library, etc;

    the framework provides the Resource Directory: ‘./build/extraResources’

    principle:

    • when generating software resource Directory enter the software installation package together
    • after the software is installed, decompress the resources to: software installation location ‘/resources/extraResources’

    resource Directory:

    1. ./build/extraResources

    use:

    1. # Different resource paths
    2. let softwarePath = '';
    3. # Old grammar
    4. if (electronApp.isPackaged) {
    5. // After packing
    6. softwarePath = path.join(this.app.config.execDir, "resources", "extraResources", softName);
    7. } else {
    8. // Before packing
    9. softwarePath = path.join(this.app.config.execDir, "build", "extraResources", softName);
    10. }
    11. # New syntax, getextraresourcesdir() will automatically determine whether the current is before packaging or after packaging
    12. softwarePath = path.join(Utils.getExtraResourcesDir(), softName);
    13. # The demo is already in the project, please check
    14. /**
    15. * Call other programs
    16. */
    17. openSoftware (softName) {
    18. .......
    19. }

    Example: powershell.exe software location in demo

    1. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    2. # Put it in the './build/extraresources' resource directory and test it