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:
./build/extraResources
use:
# Different resource paths
let softwarePath = '';
# Old grammar
if (electronApp.isPackaged) {
// After packing
softwarePath = path.join(this.app.config.execDir, "resources", "extraResources", softName);
} else {
// Before packing
softwarePath = path.join(this.app.config.execDir, "build", "extraResources", softName);
}
# New syntax, getextraresourcesdir() will automatically determine whether the current is before packaging or after packaging
softwarePath = path.join(Utils.getExtraResourcesDir(), softName);
# The demo is already in the project, please check
/**
* Call other programs
*/
openSoftware (softName) {
.......
}
Example: powershell.exe software location in demo
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
# Put it in the './build/extraresources' resource directory and test it