diff --git a/index.js b/index.js new file mode 100644 index 0000000..0d615a9 --- /dev/null +++ b/index.js @@ -0,0 +1,24 @@ +var platform = require("os").platform(); + +function _check() { + return new Promise(resolve => { + if (platform == "win32" || platform == "win64") { + require('child_process').exec('net session', function (err, stdout, stderr) { + if (err) { + resolve(false); + } else { + resolve(true); + } + }); + } else { + throw new Error('Can not determine if admin priviliges are present or not') + } + }); +} + + +exports.check = async function () { + var result = await _check(); + return result + +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..e52a834 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "admin-check", + "version": "1.1.0", + "description": "package to check if the script is runnig with admin permissions", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/denizariyan/admin-check.git" + }, + "keywords": [ + "admin", + "permission", + "check", + "is-admin", + "administrator" + ], + "author": "denizariyan", + "license": "MIT", + "bugs": { + "url": "https://github.com/denizariyan/admin-check/issues" + }, + "homepage": "https://github.com/denizariyan/admin-check#readme" +}