星期六, 九月 04, 2004

定时间段关机的批处理

参考tombkeeper的提示
https://www.xfocus.net/bbs/index.php?act=ST&f=2&t=39156

做了个定时间段关机的批处理,防止MM老是晚上上网忘了去睡觉,,想找个关机的程序,还大部分是要注册的共享软件,晕4. 下面是批处理代码,winxp/2003验证通过

@Rem write by echo521 qq:1288893

@echo off
@rem 如果检测到是自己的用户名登录的话直接退出
netsh diag show computer /v | find /i "\echo521" >nul && exit
@rem 把上面的echo521换成你不想要执行这个脚本的用户名

time /t |find "22:" >nul && goto shutdown
time /t |find "23:" >nul && goto shutdown
time /t |find "00:" >nul && goto shutdown
time /t |find "01:" >nul && goto shutdown
time /t |find "02:" >nul && goto shutdown
time /t |find "03:" >nul && goto shutdown
time /t |find "04:" >nul && goto shutdown
time /t |find "05:" >nul && goto over
time /t |find "06:" >nul && goto over
time /t |find "07:" >nul && goto over
time /t |find "08:" >nul && goto morning
time /t |find "09:" >nul && goto morning
time /t |find "10:" >nul && goto morning
time /t |find "11:" >nul && goto eat
time /t |find "12:" >nul && goto eat
time /t |find "13:" >nul && goto eat
time /t |find "14:" >nul && goto eat2
time /t |find "15:" >nul && goto eat2
time /t |find "16:" >nul && goto eat2
time /t |find "17:" >nul && goto eat3
time /t |find "18:" >nul && goto eat3
time /t |find "19:" >nul && goto eat3
time /t |find "20:" >nul && goto night
time /t |find "21:" >nul && goto night

exit

:shutdown
net send 192.168.0.1 MM,很晚了,别玩电脑去睡觉吧,注意身体---疼你的GG & shutdown /s /f /t 60
exit

:over
net send 192.168.0.1 MM,这么早就起来啦,先别玩电脑去锻炼一下,注意身体---疼你的GG & shutdown /s /f /t 60
exit

:morning
net send 192.168.0.1 玩一会儿电脑记得休息啊。---疼你的GG
exit

:eat
net send 192.168.0.1 该是吃中饭的时候了,记得去吃饭哦!--疼你的GG
exit

:eat2
net send 192.168.0.1 你吃了饭没有?没有的话赶快去吃吧,一定记得吃饭哦,还有别只顾玩却让小猫在家搞破坏啊 --疼你的GG
exit

:eat3
net send 192.168.0.1 该是吃晚饭的时候了!别告诉我你还没吃中饭啊,记得去吃饭哦,饿坏了我心疼。--疼你的GG
exit

:night
net send 192.168.0.1 别玩的太晚啊,注意身体,还有晚饭吃了没有,没有的话赶快去吃吧?--疼你的GG
exit



把以上内容存为auto.bat 放到 c:\ 下 ,再在 本地计算机策略-->用户设置--> windows设置---->脚本-(登录/注销) 的 登录 选项里添加进auto.bat的路径.

或者在计划任务里添加计划任务,为每周的一,二,三,四,五,六,日执行,并且在高级里设置在一天里每隔一小时执行一次.



Windows XP 可以识别以冒号 (:) 开头作为标签的批处理程序行并且不会将它作为命令处理。如果某行以冒号开始,则该行的任何命令都将被忽略。

是下面这个意思

goto cls
goto end
:cls
echo ok
:end
---


c:\>set
USERNAME=ALLyeSNO
so
set|find/i "=ALLyeSNO"


谢谢,昨天在研究netsh的时候也发现一个办法得到当前登录的用户名,

netsh diag show computer /v | find /i "\ALLyeSNO" >nul && exit

没有评论: