Electron Build 打包后如果安装在C:Program Files目录的问题
Electron Build 打包后如果安装在C:Program Files目录,这时候如果要写入文件你会发现会出现
Uncaught Error: EPERM: operation not permitted, open
经过测试 只要是默认C:Program Filesxxx目录好像都不行,那怎么办呢,既然这个目录不行,那就修改build
的
默认配置不就行
修改默认安装路径
如何修改,参考官网
https://www.electron.build/configuration/nsis#custom-nsis-script
How do change the default installation directory to custom?
It is very specific requirement. Do not do if you are not sure. Add custom macro:
!macro preInit SetRegView 64 WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:MyApp" WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:MyApp" SetRegView 32 WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:MyApp" WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:MyApp" !macroend
上面就是说在niss
脚本中修改即可
如
;修改默认安装路径
!macro preInit
SetRegView 64
WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:makalo-cnblog-tool"
WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:makalo-cnblog-tool"
SetRegView 32
WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:makalo-cnblog-tool"
WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:makalo-cnblog-tool"
!macroend