Configure electron-builder to run powershell script

梦想的初衷 提交于 2021-02-08 01:26:05

问题


I have an installation file created by electron-builder and faced issue that can't find a way how to run powershell script after installation.

The idea is to make some changes in windows registry and set permission for application folder.

As far as I understand it should be configured in build section in package.json. In api I found that it is exist afterPack method, but I can't figure it out how to execute powershell file through it.

Thank you.


回答1:


First, create an afterPack.js file, containing this code:

exports.default = async function () {
    const { exec } = require('child_process');
    const bat = exec('powershell "& ""path/to/powershell/file.ps1"""');
}

Edit the path to the .ps1 file accordingly. You may need to add a '.\' to the start of the path. The console readout will tell you if you do.

Next, edit your package.json file to include an afterPack parameter in your build settings, like so:

Now when you run your build script, it will run your .ps1 file.



来源:https://stackoverflow.com/questions/52724004/configure-electron-builder-to-run-powershell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!