dsheiko / nw-autoupdater

⛔️ [DEPRECATED] Library provides low-level API to control NW.js app auto-updates
MIT License
75 stars 36 forks source link

Run swap as administrator? #15

Open adamtal3 opened 6 years ago

adamtal3 commented 6 years ago

I couldn't find anyway of making the swap operation as an administrator.

It's failing for me with an EPERM error (code -4048, syscall 'unlink').

I tried opening a command line and running the call to the temp exe file myself and it failed the same, calling it in a command line opened as an administrator succeeded. I'm guessing it's because my program files directory requires UAC elevation for any changes (which was the default windows 10 behavior for me).

Can I make the swap operation elevate to admin privileges?

dsheiko commented 6 years ago

You do not need admin permissions for swap. Swap takes files from TMP (given you specified a directory accessible to the user) and replaces corresponding ones in the app. But according to your error message, seems like it's symlink issue reported in https://github.com/dsheiko/nw-autoupdater/issues/6, which not yet resolved.

adamtal3 commented 6 years ago

@dsheiko - Thanks for the response.

My error is in Windows (not mac) and the permission issue is not in the TEMP directory but in the installation directory (under Program Files). I can verify that it's solved by running the exe at the TEMP directory as admin.

I don't think it has anything to do with the symlink issue.

I tested the process on a MAC and it fails with ERROR: LSOpenURLsWithRole() failed for the application code -10810 - not sure why is that (might be also a permission issue, or maybe something wrong with the process which makes it exit with an exit code greater than 0).

adamtal3 commented 6 years ago

@dsheiko - About the MAC issue, I've made some tests and it seems that if I use exec instead of spawn it manages to open the app. Do you have any explanation? If that makes sense I'll create a PR for this.

dsheiko commented 6 years ago

But I use spawn to create a detached process. If you try to replace your app on a child of the same process, it will report files are locked

adamtal3 commented 6 years ago

I managed to run the process with my fork using exec on MAC.. It just didn't work with spawn.

If you have any idea what the cause of the issue with spawn is I'll be glad to use a better solution for it.