electron 啟動其他應(yīng)用
借助node的child_process模塊
下面是命令
window
檢測用戶是否安裝
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\|find /i "應(yīng)用(可能會是一個hash)"
如果有就會返回路徑,沒有就什么都不返回
檢測用戶是否啟動
wmic process where caption=”XXXX.exe” get caption,commandline /value
殺死某個進(jìn)程
taskkill /F /IM XXX.exe
啟動
start 應(yīng)用絕對路徑
mac
檢測用戶是否安裝
沒有的話就會報(bào)錯
const log = spawn('osascript', ['-e', 'id of application \"應(yīng)用名字\"']);
const log = spawn('osascript', ['-e', 'id of application \"應(yīng)用名字\"']);
let buffer = '';
log.stdout.on('data', (data) => { buffer += data });
log.stdout.on('end', () => {})
log.stderr.on('data', (err) => { console.log('err', err) });
log.stderr.on('end', () => {});
mac檢測是否在運(yùn)行
const log = exec('ps -e | grep -v grep | grep "應(yīng)用名字"');
let is_running = false;
log.stdout.on('data', () => {
is_running = true;
});
log.stdout.on('end', () => {
if (is_running) {
console.log(11);
} else {
console.log(222);
}
});
log.stderr.on('data', () => {});
log.stderr.on('end', () => {});
mac 殺死進(jìn)程
killall 應(yīng)用名字
啟動應(yīng)用
open -a 應(yīng)用.app