-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from miguelx97/feature/microsoft-store-support
Add microsoft store support
- Loading branch information
Showing
3 changed files
with
64 additions
and
5 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,52 @@ | ||
fs = require 'fs' | ||
path = require 'path' | ||
Winreg = require 'winreg' | ||
|
||
|
||
regKey = new Winreg | ||
hive: Winreg.HKCU | ||
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' | ||
|
||
|
||
module.exports = | ||
|
||
### Public ### | ||
|
||
# options - {Object} | ||
# :appName - {String} | ||
# :appPath - {String} | ||
# :isHiddenOnLaunch - {Boolean} | ||
# Returns a Promise | ||
enable: ({appName, appPath, isHiddenOnLaunch}) -> | ||
return new Promise (resolve, reject) -> | ||
pathToAutoLaunchedApp = appPath | ||
args = '' | ||
|
||
args += ' --hidden' if isHiddenOnLaunch | ||
|
||
regKey.set appName, Winreg.REG_SZ, "\"C:\\Windows\\explorer.exe\" shell:AppsFolder\\#{pathToAutoLaunchedApp}#{args}", (err) -> | ||
return reject(err) if err? | ||
resolve() | ||
|
||
|
||
# appName - {String} | ||
# Returns a Promise | ||
disable: (appName) -> | ||
return new Promise (resolve, reject) -> | ||
regKey.remove appName, (err) -> | ||
if err? | ||
# The registry key should exist but in case it fails because it doesn't exist, resolve false instead | ||
# rejecting with an error | ||
if err.message.indexOf('The system was unable to find the specified registry key or value') isnt -1 | ||
return resolve false | ||
return reject err | ||
resolve() | ||
|
||
|
||
# appName - {String} | ||
# Returns a Promise which resolves to a {Boolean} | ||
isEnabled: (appName) -> | ||
return new Promise (resolve, reject) -> | ||
regKey.get appName, (err, item) -> | ||
return resolve false if err? | ||
resolve(item?) |
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