-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a83c40
commit 0f64ae7
Showing
2 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
} |
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,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" | ||
} |