nw-updater icon indicating copy to clipboard operation
nw-updater copied to clipboard

Windows 8.1 not completing update process

Open hermwong opened this issue 10 years ago • 15 comments

Here are the steps that occur when I use the node-webkit-updater on Windows 8.1:

  1. app detects a new version available
  2. new version is downloaded & unzipped to temp directory
  3. app closes
  4. the new app in temp directory doesn't run
  5. the new app doesn't get copied from the temp directory to the app's exec/install directory

Basically the app will download the updated version and then quit, but won't relaunch the downloaded new version.

hermwong avatar Feb 03 '15 23:02 hermwong

Did you try using gui.Shell.openItem?

adam-lynch avatar Feb 06 '15 14:02 adam-lynch

I'm basically using the example code, on OSX it is able to detect, download, update and relaunch my app, however on Windows it only seems to detect and download my app but never performs the update and relaunch.

hermwong avatar Feb 06 '15 22:02 hermwong

Instead of upd.run(execPath, null);, try gui.Shell.openItem(execPath).

adam-lynch avatar Feb 06 '15 22:02 adam-lynch

Thanks @adam-lynch, I'll give it a try and let you know how it goes.

hermwong avatar Feb 06 '15 22:02 hermwong

I'm getting the same result with gui.Shell.openItem(execPath); it works on OSX but fails on Windows 8.1.

hermwong avatar Feb 09 '15 21:02 hermwong

Is execPath what you'd expect? (The path to the .exe of the new update)

adam-lynch avatar Feb 09 '15 21:02 adam-lynch

I have problem on Windows 8.1 too, I check my code,and found : 1、app detects a new version available 2、new version is downloaded & unzipped to temp directory 3、app closes 4、the new app in temp directory run 5、the new app doesn't get copied from the temp directory to the app's exec/install directory, And I check the old version folder ,it was occupied by the new app run from temp directory.

MichaelIT avatar Apr 06 '15 23:04 MichaelIT

I resolved my problem by create a bat file and gui.Shell.openItem() to run my update app as a new instance of nw. var pathName = path.dirname(newAppPath) var installName = pathName + "/install.bat"
fs.writeFileSync(installName,newAppPath+" "+ upd.getAppPath() + " "+upd.getAppExec(), "UTF-8",{'flags': 'w+'}); gui.Shell.openItem(installName) gui.App.quit();

MichaelIT avatar Apr 07 '15 00:04 MichaelIT

@Michael00767

And I check the old version folder ,it was occupied by the new app run from temp directory.

This sounds like it is being copied?

I'm not sure you need to do what you're doing.

adam-lynch avatar Apr 07 '15 22:04 adam-lynch

@adam-lynch

Here is what I'm seeing when retrieving the various paths (on Windows 8.1):

newAppPath = C:\Users\hermwong\AppData\Local\Temp\PhoneGap-Desktop-Beta-0.1.4-win\PhoneGap.exe upd.getAppExec() = C:\Program Files (x86)\Adobe\PhoneGap\PhoneGap Desktop\ upd.getAppPath() = C:\Program Files (x86)\Adobe\PhoneGap\PhoneGap Desktop\

When I execute: upd.runInstaller(newAppPath, [copyPath, execPath],{});, my App crashes

hermwong avatar Apr 21 '15 22:04 hermwong

I've attached the screenshot of the error message from the App crash.

screen shot 2015-04-21 at 3 27 11 pm

Uncaught node.js Error

Error: spawn ENOENT
    at exports._errnoException (util.js:742:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1027:32)
    at child_process.js:1110:20
    at process._tickCallback (node.js:382:11)

hermwong avatar Apr 21 '15 22:04 hermwong

Hey guys!! This is an awesome app! I have local copy totally slaughtered so I can't test this quickly.. But I think I know the problem... when you call -> upd.run(execPath, null); spawn gets a spawn("string", null, {xxx}); I think is not liking it! Try upd.run(execPath, []); or change updater.js so it gets a [] as a second parameter instead of null

aacotroneo avatar Sep 02 '15 16:09 aacotroneo

Has anyone found a confirmed way to work around this bug? I'm experiencing the same trouble on Windows 10—the .zip file downloads and extracts, but the new process never starts up when the old version quits.

amsoell avatar Jun 21 '16 19:06 amsoell

Hmm @hermwong this is weird. The result of getAppPath and getAppPath should never be the same on Windows. See here https://github.com/edjafarov/node-webkit-updater/blob/master/app/updater.js#L138 that getAppExec is the result of joining getAppPath (the parent directory of the app) and the app's basename (therefore it's just process.execPath really).

adam-lynch avatar Jul 02 '16 23:07 adam-lynch

did you try what I mentioned @amsoell ? child_process.spawn signature is (String[, Array][, Object]), and the updater ends up invoking with (<String>, null, <Object>). It's a 5 minutes check man https://github.com/edjafarov/node-webkit-updater/blob/master/examples/basic.js#L29

aacotroneo avatar Jul 03 '16 01:07 aacotroneo