本帖最后由 ygqiang 于 2014-11-26 23:58 编辑
[已解决]xp系统,bat批处理:自动判断某个时间段,自动关机。为啥有时关不了机呢?
屏幕上只有鼠标指针能动,桌面啥的都没有了。- @echo off
- if "%1" == "h" goto begin
- mshta vbscript:createobject("wscript.shell").run("%~fs0 h",0)(window.close)&&exit
- :begin
- rem 下边开始写批处代码了
-
- ping 127.0.0.1 -n 30 >nul 2>nul
-
- sc config schedule start= demand
- net start schedule
-
-
- ——————————————————————————————————————————————————————
- 先用tasklist 输入进程列表给find ,让find找出exe进程,如果找到,就goto跳转。找不到就执行下面的操作
- tasklist|find /i "软件1.EXE" &&goto :first2
-
- 先用tasklist 输入进程列表给find ,让find找出EXE进程,如果找到,那执行下面的操作。找不到就goto
- tasklist|find /i "软件2.EXE" ||goto :first3
-
-
-
- ——————————————————————————————————————————————————————
- :first1
-
- set "t=%time: =0%"
- if "%t:~,5%" geq "12:20" if "%t:~,5%" leq "12:25" goto :first11
- if "%t:~,5%" geq "21:50" if "%t:~,5%" leq "21:55" goto :first11
- ping 127.0.0.1 -n 40 >nul 2>nul
- goto :first1
-
-
- :first11
- taskkill /f /im 软件2.EXE
- taskkill /f /im AutoRedrCard.EXE
- ping 127.0.0.1 -n 5 >nul 2>nul
- shutdown -s -f -t 5
-
-
- ——————————————————————————————————————————————————————
- :first2
-
- set "t=%time: =0%"
- if "%t:~,5%" geq "21:50" if "%t:~,5%" leq "21:55" goto :first21
- ping 127.0.0.1 -n 40 >nul 2>nul
- goto :first2
-
-
- :first21
- taskkill /f /im 软件1.EXE
- taskkill /f /im AutoRedrCard.EXE
- ping 127.0.0.1 -n 5 >nul 2>nul
- shutdown -s -f -t 5
-
-
- ——————————————————————————————————————————————————————
- :first3
-
- set "t=%time: =0%"
- if "%t:~,5%" geq "21:10" if "%t:~,5%" leq "21:15" goto :first31
- ping 127.0.0.1 -n 40 >nul 2>nul
- goto :first3
-
-
- :first31
- ping 127.0.0.1 -n 5 >nul 2>nul
- shutdown -s -f -t 5
复制代码
|