guest
Version:
Lets you enable or disable guest account access on Linux, Mac and Windows.
30 lines (24 loc) • 757 B
JavaScript
var exec = require('child_process').exec;
// var guest_account_name = 'Guest User';
var guest_account_name = 'Guest';
function call(method, cb) {
var cmd = 'net user "' + guest_account_name + '"';
if (method) cmd += ' /' + method;
exec(cmd, cb);
}
exports.check = function(cb) {
call(null, function(err, out, stderr) {
// if user does exist, exec() returns an error (code/errorlevel 2)
// if (err) return cb(err);
// failed message is 'The user name could not be found.'
// var exists = !stderr.match('could not be found');
var exists = !!out.toString().match(/activ.*yes/i);
cb(null, exists);
})
}
exports.enable = function(cb) {
call('active:yes', cb)
}
exports.disable = function(cb) {
call('active:no', cb)
}