const { exec } = require('child_process');
//关机
function shutdownWindow() {
let command = exec('shutdown -s -t 00', function (err, stdout, stderr) {
if (err || stderr) {
console.log("shutdown failed" + err + stderr);
}
});
command.stdin.end();
command.on('close', function (code) {
console.log("shutdown", code);
});
}
//重启
function rebootWindow() {
let command = exec('reboot', function (err, stdout, stderr) {
if (err || stderr) {
console.log("reboot failed" + err + stderr);
}
});
command.stdin.end();
command.on('close', function (code) {
console.log("reboot", code);
});
}
setInterval(() => {
let endtime = new Date('2023-10-09 21:01:00').getTime();
let nowtime = new Date().getTime()
console.log(endtime, nowtime)
if (endtime < nowtime) {
shutdownWindow()
}
}, 1000)
07-24
611
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交