Skip to content

Commit

Permalink
Merge pull request Teamwork#35 from GPMDP/master
Browse files Browse the repository at this point in the history
Use the Squirrel Update.exe processStart method to launch the latest version of each app
  • Loading branch information
Alan Smith authored Aug 10, 2016
2 parents 5953a13 + fe1f76d commit 9cbca0e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/AutoLaunchWindows.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fs = require 'fs'
path = require 'path'
Winreg = require 'winreg'
Promise = require('es6-promise').Promise

Expand All @@ -11,8 +13,15 @@ module.exports =

enable: (opts) ->
new Promise (resolve, reject) ->
appPath = opts.appPath
arg = ""
updateDotExe = path.join(path.dirname(process.execPath), '..', 'update.exe')
versions = process?.versions
if fs.existsSync(updateDotExe) and versions.electron
appPath = updateDotExe
arg = " --processStart \"#{path.basename(process.execPath)}\""
hiddenArg = if opts.isHiddenOnLaunch then ' --hidden' else ''
regKey.set opts.appName, Winreg.REG_SZ, "\"#{opts.appPath}\"#{hiddenArg}", (err) ->
regKey.set opts.appName, Winreg.REG_SZ, "\"#{appPath}\"#{arg}#{hiddenArg}", (err) ->
return reject(err) if err?
resolve()

Expand Down

0 comments on commit 9cbca0e

Please sign in to comment.