Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Introduction
In advanced applications in, Electron process by way calling, call the operating system executable files such as .exe files in the windows system. In Electron Engineering, packaged into a package by Electron-Buider installation process, you need to pay attention to the following matters.
Precautions
JS代码里,指定的对相对或绝对目录的.exe文件的调用,在用Electron-Buider打包后,不会受到破坏。但是,该.exe文件及其目录不会被打包,所以需要打包后,手动将该.exe文件及目录拷贝到打包后的unpacked类型绿色目录,便于后期再进一步打包成单个安装文件。
JS代码里,用__dirname设定的目录,在工程环境使用正常,但是用Electron-Buider打包后,__dirname会被修改,不再是指向当前的目录,而是resources目录下的.asar文件里,故容易产生故障。解决的办法1是采用绝对目录,解决的办法2是不采用__dirname的方式,采用其它方式准确指定目录。
Exe files packed scenes
典型的应用场景为exe文件为setup.exe文件,即为某种工具(如MongoDB)的安装包,通过Electron整体打包后,在执行Electron软件安装时,也同时将工具安装文件放置,并在程序里,设置第一次启动时,触发安装该工具。如此,不必为用户提供单独的工具安装包。
–End–