#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char input[20];
system("shutdown -s -t 120"); // 2 分鐘後關機
while (1) {
printf("2 分鐘後關機,輸入 \"我好帥\" 取消: ");
scanf("%s", input);
if (strcmp(input, "我好帥") == 0) {
system("shutdown -a"); // 取消關機
printf("已取消關機\n");
break;
}
printf("輸入錯誤,請重試。\n");
}
return 0;
}
shutdown -s -t 120:設置 120 秒後關機。shutdown -a:中止關機計劃。Win+R 輸入 shutdown -a 即可中止,或編寫同名 .bat 執行同樣命令。
僅供學習系統命令調用,請勿惡意使用。