New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get executable APP name in main.js for portable #3186

Closed
Cefold opened this Issue Jul 29, 2018 · 14 comments

Comments

Projects
None yet
2 participants
@Cefold
Copy link

Cefold commented Jul 29, 2018

I see that process.env.PORTABLE_EXECUTABLE_DIR will return executable dir, but how can I get full app name, assume some users would change that app name?

I want to toggle shortcut and startup, which will need dir and app name, C:/Users/${user}/AppData/Local/Temp is not useful since it will change every time.

System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("PORTABLE_EXECUTABLE_DIR", "$EXEDIR").r0'

It only sets PORTABLE_EXECUTABLE_DIR.

@develar

This comment has been minimized.

@develar develar added the feature label Jul 29, 2018

@develar develar added the nsis label Jul 29, 2018

@develar

This comment has been minimized.

Copy link
Member

develar commented Jul 29, 2018

Env PORTABLE_EXECUTABLE_APP_FILENAME is added.

@develar

This comment has been minimized.

Copy link
Member

develar commented Jul 29, 2018

Yeach, server side of snap implemented in Go, but why, why client side in Python :(

develar added a commit that referenced this issue Jul 29, 2018

develar added a commit to develar/electron-builder that referenced this issue Jul 29, 2018

@Cefold

This comment has been minimized.

Copy link

Cefold commented Jul 29, 2018

Yes, that's what I needed, thanks.
I have a rookie question, when can I use the new feature? The newest version v20.26.1 does not have this feature.

By the way, what is the difference from APP_FILENAME and APP_EXECUTABLE_FILENAME?

@develar

This comment has been minimized.

Copy link
Member

develar commented Jul 30, 2018

@develar develar closed this in 8d966f8 Jul 31, 2018

@Cefold

This comment has been minimized.

Copy link

Cefold commented Jul 31, 2018

I tried the new feature, but PORTABLE_EXECUTABLE_APP_FILENAME will return the name in package.json, not the real portable app name.
More importantly, the PORTABLE_EXECUTABLE_APP_FILENAME is fixed.

For example, package.json file has "name": "MyAPP", "productName": "my.app",
I will get a portable app my.app 1.0.0.exe, but PORTABLE_EXECUTABLE_APP_FILENAME will return MyAPP, if I change the APP name, the return value stays the same. What I want is getting my.app 1.0.0, and if I change that file name to anotherAPP.exe, PORTABLE_EXECUTABLE_APP_FILENAME should return anotherAPP.

@develar develar reopened this Jul 31, 2018

@develar

This comment has been minimized.

Copy link
Member

develar commented Jul 31, 2018

https://www.electron.build/configuration/nsis/#portable

PORTABLE_EXECUTABLE_ it is a common prefix for all envs that set by portable wrapper.

By the way, what is the difference from APP_FILENAME and APP_EXECUTABLE_FILENAME?

APP_EXECUTABLE_FILENAME is not for users (you are electron-builder user), it is internal developer only name. In the docs PORTABLE_EXECUTABLE_APP_FILENAME described as "sanitized app name to use in file paths."

Now I realised that you want PORTABLE_EXECUTABLE_FILE (full path to portable wrapper).

@Cefold

This comment has been minimized.

Copy link

Cefold commented Jul 31, 2018

Yes, I need full path, include portable wrapper, to set shortcut and startup. I know it does not make much sense to give portable app such functions like toggling shortcut and startup, but some users really like to have those functions for portable app.

The hard part is that user might change the portable wrapper name. E.g. if I hardcode the name to my.app 1.0.0.exe, and user change it to something like anotherAPP.exe, the functions used that name will not work.

I guess that name should be passed from nsis to node env, but it seems portable mode does not support Custom NSIS script.

@develar

This comment has been minimized.

Copy link
Member

develar commented Jul 31, 2018

What shortcut do you mean?

@Cefold

This comment has been minimized.

Copy link

Cefold commented Jul 31, 2018

Desktop shortcut.

@develar

This comment has been minimized.

Copy link
Member

develar commented Jul 31, 2018

Why do you use portable in this case?

@Cefold

This comment has been minimized.

Copy link

Cefold commented Jul 31, 2018

I don't want to use portable, that's users request, some people really hate to install something or unzip something, they just want a single executable, even it will create a tmp folder and unzip everything to that folder every time and slower than normal way.

@develar develar closed this in dfa9f7d Aug 7, 2018

@develar

This comment has been minimized.

Copy link
Member

develar commented Aug 7, 2018

@Cefold Please try 20.27.1

@Cefold

This comment has been minimized.

Copy link

Cefold commented Aug 8, 2018

Great, now PORTABLE_EXECUTABLE_APP_FILENAME will return full path, and path.basename(process.env.PORTABLE_EXECUTABLE_FILE) will return executable name.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment