use windows query.exe
to do the query and return the results
queryUser | querySession | queryProcess (options, callback)
options
- timeout : default: 5000, if the
query
command hang there for some reason, set this value to force return error and kill the process. - serverName : corresponding to the
/SERVERNAME
option ofquery.exe
Note: options can be omitted to use the default values
var winQueryUtils = require('win-query-utils');
var _ = require('lodash');
winQuerUtils.querySession(function(err, data) {
if (!err) {
console.log('Active session id of user TestUser is: ' +
_.find(data, { state: 'Active', username: 'TestUser' }).sessionId);
}
};
- queryUser returns the results of command
query user
[
{
username: 'string',
sessionName: 'string',
sessionId: 'string',
state: 'string',
idleTime: 'string',
logonTime: 'string'
}
]
- querySession returns the results of command
query session
[
{
sessionName: 'string',
username: 'string',
sessionId: 'string',
state: 'string',
type: 'string',
device: 'string'
}
]
- queryProcess returns the results of command
query process
[
{
username: 'string',
sessionName: 'string',
sessionId: 'string',
processId: 'string',
processName: 'string'
}
]