forked from hainproject/hain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix auto-launch not working on installed program
- Loading branch information
Heejin Lee
committed
Sep 3, 2016
1 parent
c984ea0
commit 7695331
Showing
3 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
const Registry = require('winreg'); | ||
|
||
module.exports = class AutoLauncher { | ||
constructor(opts) { | ||
this.appName = opts.name; | ||
this.appPath = opts.path; | ||
this.reg = new Registry({ | ||
hive: Registry.HKCU, | ||
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' | ||
}); | ||
} | ||
enable() { | ||
return new Promise((resolve, reject) => { | ||
this.reg.set(this.appName, Registry.REG_SZ, this.appPath, (err) => { | ||
if (err) | ||
return reject(err); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
disable() { | ||
return new Promise((resolve, reject) => { | ||
this.reg.remove(this.appName, (err) => { | ||
if (err) | ||
return reject(err); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
isEnabled() { | ||
return new Promise((resolve, reject) => { | ||
this.reg.get(this.appName, (err, item) => { | ||
resolve(item != null); | ||
}); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters