mirror of
https://github.com/fofolee/uTools-ProcessKiller.git
synced 2025-12-22 18:22:17 +08:00
v0.0.1
This commit is contained in:
26
preload.js
Normal file
26
preload.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const exec = require('child_process').exec;
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
window.tasklist = (callback) => {
|
||||
// if(process.platform === 'win32'){}
|
||||
let cmd = 'tasklist /FO csv /NH /V'
|
||||
exec(cmd, function (err, stdout, stderr) {
|
||||
let tasklist = [];
|
||||
let lines = stdout.trim().split('\n');
|
||||
for (var line of lines){
|
||||
tasklist.push(line.trim().split(','));
|
||||
}
|
||||
callback(tasklist);
|
||||
})
|
||||
}
|
||||
|
||||
window.taskkill = (taskname, callback) => {
|
||||
let cmd = 'TASKKILL /F /IM "' + taskname + '" /T'
|
||||
exec(cmd, { encoding: "buffer"}, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
callback(iconv.decode(stderr,'cp936'));
|
||||
return;
|
||||
}
|
||||
callback(iconv.decode(stdout,'cp936'));
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user