Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get os edition for windows 11 #535

Merged
merged 4 commits into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions lib/system/windows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var path = require('path'),
os = require('os'),
needle = require('needle'),
cp = require('child_process'),
si = require('systeminformation'),
paths = require('./../paths'),
exec = cp.exec,
spawn = cp.spawn,
Expand Down Expand Up @@ -84,18 +85,35 @@ exports.find_logged_user = function(callback) {
exports.get_os_edition = (callback) => {
if (os_name != "windows") return callback(new Error('Only for Windows'));

wmic.get_value('os', 'caption', null, (err, stdout) => {
if (err || stdout.toString().trim() == '')
return callback(err || new Error('No edition found.'));
var common = require('./../../agent/common'),
gte = common.helpers.is_greater_or_equal;

if (gte(common.os_release,"10.0.20000")) { //10.0.20000 is w11
si.osInfo((stdoutsi) => {
if (!stdoutsi || !stdoutsi.distro || stdoutsi.distro.toString().trim() == '')
return callback(new Error('No edition found.'));

var edition = stdoutsi.distro.split(" ").splice(3)[0];

if (edition == "Business") edition = "Pro";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linea 98 y 100 se repite en la 112 y 114, ¿es posible moverlo fuera del IF?


var edition = stdout.split(" ").splice(3)[0];
callback(null,edition);
})
} else {
wmic.get_value('os', 'caption', null, (err, stdout) => {
if (err || stdout.toString().trim() == '')
return callback(err || new Error('No edition found.'));

if (!edition || edition == '')
return callback(err || new Error('No edition found.'));
var edition = stdout.split(" ").splice(3)[0];

if (edition == "Business") edition = "Pro";
callback(null, edition);
})
if (!edition || edition == '')
return callback(err || new Error('No edition found.'));

if (edition == "Business") edition = "Pro";

callback(null,edition);
})
}
}

exports.get_winsvc_version = function(callback) {
Expand Down
73 changes: 15 additions & 58 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"semver": "^5.6.0",
"sqlite3": "5.0.2",
"sudoer": "git://github.com/javo/sudoer.git#8d5619a1acdd7d37fa688a7ea5c041cb5e3cb697",
"systeminformation": "^5.9.17",
"tuna": "0.0.2",
"uid-number": "0.0.5",
"underscore": "^1.9.1",
Expand Down