Skip to content

Commit 9cbca0e

Browse files
author
Alan Smith
authored
Merge pull request #35 from GPMDP/master
Use the Squirrel Update.exe processStart method to launch the latest version of each app
2 parents 5953a13 + fe1f76d commit 9cbca0e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/AutoLaunchWindows.coffee

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fs = require 'fs'
2+
path = require 'path'
13
Winreg = require 'winreg'
24
Promise = require('es6-promise').Promise
35

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

1214
enable: (opts) ->
1315
new Promise (resolve, reject) ->
16+
appPath = opts.appPath
17+
arg = ""
18+
updateDotExe = path.join(path.dirname(process.execPath), '..', 'update.exe')
19+
versions = process?.versions
20+
if fs.existsSync(updateDotExe) and versions.electron
21+
appPath = updateDotExe
22+
arg = " --processStart \"#{path.basename(process.execPath)}\""
1423
hiddenArg = if opts.isHiddenOnLaunch then ' --hidden' else ''
15-
regKey.set opts.appName, Winreg.REG_SZ, "\"#{opts.appPath}\"#{hiddenArg}", (err) ->
24+
regKey.set opts.appName, Winreg.REG_SZ, "\"#{appPath}\"#{arg}#{hiddenArg}", (err) ->
1625
return reject(err) if err?
1726
resolve()
1827

0 commit comments

Comments
 (0)