mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-10 13:23:41 +00:00
Updated process-manager to support an options object, for search
Added win-utils to provide windows specific helper methods. Added ability to set/query system taskbar autohide on Windows
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -350,7 +350,7 @@ function processManager() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.getProcessEx = function getProcessEx(cmd)
|
this.getProcessEx = function getProcessEx(cmd, options)
|
||||||
{
|
{
|
||||||
if (process.platform == 'win32')
|
if (process.platform == 'win32')
|
||||||
{
|
{
|
||||||
@@ -361,10 +361,13 @@ function processManager() {
|
|||||||
for(i in j)
|
for(i in j)
|
||||||
{
|
{
|
||||||
if(j[i].cmd.toLowerCase() == cmd.toLowerCase())
|
if(j[i].cmd.toLowerCase() == cmd.toLowerCase())
|
||||||
|
{
|
||||||
|
if (options == null || options.path.toLowerCase() == j[i].path.toLowerCase())
|
||||||
{
|
{
|
||||||
result.push(j[i].pid);
|
result.push(j[i].pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|||||||
56
modules/win-utils.js
Normal file
56
modules/win-utils.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2022 Intel Corporation
|
||||||
|
@author Bryan Roe
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// win-utils provides helper functions for Windows Platforms
|
||||||
|
//
|
||||||
|
var reg = require('win-registry');
|
||||||
|
|
||||||
|
function winutils()
|
||||||
|
{
|
||||||
|
this._ObjectID = 'win-utils';
|
||||||
|
this.taskBar =
|
||||||
|
{
|
||||||
|
autoHide: function autoHide(tsid, value)
|
||||||
|
{
|
||||||
|
var domain = require('user-sessions').getDomain(tsid);
|
||||||
|
var user = require('user-sessions').getUsername(tsid);
|
||||||
|
var key = reg.usernameToUserKey({ domain: domain, user: user });
|
||||||
|
if(value==null)
|
||||||
|
{
|
||||||
|
// Query the Current State
|
||||||
|
var rv = reg.QueryKey(reg.HKEY.Users, key + '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3', 'Settings');
|
||||||
|
return (rv[8] == 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var rv = reg.QueryKey(reg.HKEY.Users, key + '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3', 'Settings');
|
||||||
|
rv[8] = value === true ? 3 : 2;
|
||||||
|
reg.WriteKey(reg.HKEY.Users, key + '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3', 'Settings', rv);
|
||||||
|
var pids = require('process-manager').getProcessEx('explorer.exe');
|
||||||
|
if(pids.length == 1)
|
||||||
|
{
|
||||||
|
process.kill(pids[0]);
|
||||||
|
}
|
||||||
|
return (this.autoHide(tsid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = new winutils();
|
||||||
Reference in New Issue
Block a user