Search code examples
electronportable-applications

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


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\temp folder rather than the actual '.exe' file

Is there any way to get the original app.exe path?

I've tried the following:

  • app.getAppPath()
  • __dirname
  • require.main.filename
  • app-root-path
  • and a few node modules

The path I'm getting from my tests:

C:\Users\xxx\AppData\Local\Temp\xxxxxx.tmp\app

the actual .exe Path (where the app launched from, and what i need):

C:\Users\XXX\Documents\test\dist

I'm just starting with Electron.


Solution

  • I found a solution: Use the Environment Variable (created by Electron-Builder)

    process.env.PORTABLE_EXECUTABLE_DIR
    

    to show the real Path of the App.exe. Works only packed with Electron-Builder