Rastaking Rastaking - 2 months ago 11
Node.js Question

node webkit disable autolauncher in year +1

I am working on a desktop app, and i need to disable the autolaucher if year is 2018 for exp.

var AutoLaunch = require('auto-launch');
var appLauncher = new AutoLaunch({
name: 'app'
});

appLauncher.isEnabled().then(function (enabled) {
if (enabled)
return;
return appLauncher.enable()
}).then(function (err) {
});


You have any ideas ? :)

Thanks

Answer

We can disable the auto-launch at any time using :

appLauncher.disable();

This is the full code :

var today = new Date();
var year = today.getFullYear();
var AutoLaunch = require('auto-launch');
var appLauncher = new AutoLaunch({
    name: 'app',
});

appLauncher.isEnabled().then(function (enabled) {
    console.log("start  ", enabled);
    if (enabled && year > "2016") {
        return  appLauncher.disable();
    }
    if (enabled) {
        return;
    }
    return appLauncher.enable();

}).then(function (err) {
});

Hope this will help :)