-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
34 lines (31 loc) · 871 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var WinReg = require('winreg');
var startOnBoot = {
enableAutoStart: function(name, file, callback){
var key = getKey();
key.set(name, WinReg.REG_SZ, file, callback || noop);
},
disableAutoStart: function(name, callback){
var key = getKey();
key.remove(name, callback || noop);
},
getAutoStartValue: function(name, callback){
var key = getKey();
key.get(name, function(error, result){
if(result){
callback(result.value);
}
else{
callback(null, error);
}
});
}
};
var RUN_LOCATION = '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
function getKey(){
return new WinReg({
hive: WinReg.HKCU, //CurrentUser,
key: RUN_LOCATION
});
}
function noop(){}
module.exports = startOnBoot;