How to get the original path of a portable Electron app?

前端 未结 7 1905
伪装坚强ぢ
伪装坚强ぢ 2020-12-24 08:08

I have an Portable Electron App (packed with: electron-builder + asar, portable build) on Windows. I try to get the application path but it returns a path within the user\\t

7条回答
  •  感情败类
    2020-12-24 08:40

    I had a lot of trouble with this and was finally able to solve the issue by replacing __dirname by '.', see working example below :

    const path = require('path')
    const myAppPath = path.resolve('.', 'myapp.exe');
    

提交回复
热议问题