How can I get the application path of a portable Electron app on Windows?


I have an Electron app that’s bundled into a portable App so that it’s a standalone ‘.app’ on Mac OS X and ‘.exe’ on Windows that requires no installation. On Mac OS X I can easily get the application path to determine where it is in the local file system when run. On Windows however every time I try to get the application path it returns a path within the tempdata folder rather than where the actual ‘.exe’ file resides. Apparently it’s unpacking the portable ‘.exe’ into the temp area to run from there?

I’ve tried using the first argument, app.getAppPath(), app.getPath(‘exe’), and window.require.main.filename but they all return the same tempdata path when the app is run from a portable bundle ‘.exe’

Is there any way to get the original path of the actual ‘.exe’ itself before it unpacks into the tempdata area?

I’m getting this:

but the actual .exe is launched from here at the moment:



I previously used LiveCode to develop cross-platform apps and packaged them into similar portable apps. In a self-contained LiveCode App on Windows the App path reported the path to the original self-contained application on the Windows’ hard drive, not a temp path like Electron does.

Here’s an older app I developed in LiveCode where it can tell where it is when launched on Mac or Windows.

Here’s a newer app I developed in Electron where it can tell where it is when launched on Mac but not on Windows. On Windows it only finds the temp directory where it must be temporarily unpacking to?


BTW: This is an app that’s packaged as a portable app using electron-builder.

So how do you get the portable app path where the app is in the filesystem from a portable app packaged with electron-builder on Windows? Using the normal methods all give me the path to the temp directory where it unpacks to run, not the original path where the portable app is located. Can it be done?


I have the same problem with you


Have you come up with any workaround?


Can you not use the variable __dirname?


I tried that first but all that returns is: ‘/src\containers’

That’s the path within the project folder to the source file. What I need is the path to the packaged portable app itself in the file system.
For example this path if I run the packaged portable app from the dist directory right after packing.


app.getAppPath() works fine on Mac OS X, but not on Windows (for a portable app).


hey there,
i have the same problem.
any solutions or tipps out there?


You can use this function to get the USER account which is like this C:/USERS/{username}/

function getUserHome() {
return process.env[(process.platform == ‘win32’) ? ‘USERPROFILE’ : ‘HOME’];

let me know if it helped it. And yes if you want to know where in windows they load the appdata then its

remember, you will get a path through this function.


Thanks but that’s not really what I need. I need to know where the portable application file happens to be located, in a portable app that the user may run from wherever they want. It’s not installed to a specific directory. They drag it where they want it and run it from there. So I want to have the app know where it is located when launched.


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


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


I’ll give that a spin on my next update!