定时关机的批处理与vbs编程
我利用业余时间编写了程序(限时定时器),与广大喜爱编程的朋友相互学习,相互促进!主要功能:
1.家长事先设定上网的时长(需是1,2,3,4等整数,时间单位默认是小时),到时将有警告声提示,只有输入了正确的密码后才不致迅速关机,不输或输入了错误的密码,电脑将在30秒后自动关机
2.也可把你的隐私或秘密藏起来,双击“密藏.bat”即可,想看你的隐私或秘密就得知道密码
3.闹钟提醒功能会及时提醒你别误了大事
提取限时定时器请点击 http://pickup.mofile.com/9955682335143937
或登录 http://file.mofile.com/ ,使用提取码 9955682335143937 提取文件
源码附后:将下面代码复制之后保存为bat文件即可。如:123.bat
@cls
@md d:\h3000
@echo ------------------------------------------------------
@echo ---------设置管理密码,然后按回车键-------------------
@echo -------------------记住密码---------------------------
@set /p m=
@echo ------------------------------------------------------
@echo -----------设置限定时间,然后按回车键-----------------
@echo -----------输一位整数,默认单位是小时-----------------
@set /p h=
@set /a h=%h%*3600000
@echo %h%
@echo A=msgbox("重启电脑后生效.现在就重启吗?",4,vbYesNo) >d:\h3000\gaozhi.vbs
@echo If A = 6 Then >>d:\h3000\gaozhi.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\gaozhi.vbs
@echo BatRunner.run "cmd /c shutdown /t 0 " >>d:\h3000\gaozhi.vbs
@echo End If >>d:\h3000\gaozhi.vbs
@echo WScript.Sleep 30000 >d:\h3000\bey.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\bey.vbs
@echo BatRunner.run "cmd /c shutdown /t 0 " >>d:\h3000\bey.vbs
@echo set ws=wscript.createobject("wscript.shell") >d:\h3000\xsq.vbs
@echo WScript.Sleep %h% >>d:\h3000\xsq.vbs
@echo set ws=wscript.createobject("wscript.shell") >>d:\h3000\xsq.vbs
@echo ws.run "d:\h3000\bey.vbs /start",0 >>d:\h3000\xsq.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\xsq.vbs
@echo BatRunner.run "cmd /c mplay32.exe /play /close C:\WINDOWS\Media\ringin.wav" >>d:\h3000\xsq.vbs
@echo for i=1 to 4 >>d:\h3000\xsq.vbs
@echo x=inputbox("输入密码延时!","电脑将在30秒钟后自动关机!","0") >>d:\h3000\xsq.vbs
@echo if x = %m% then >>d:\h3000\xsq.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\xsq.vbs
@echo BatRunner.run "cmd /c taskkill /f /im wscript.exe" >>d:\h3000\xsq.vbs
@echo exit for >>d:\h3000\xsq.vbs
@echo else >>d:\h3000\xsq.vbs
@echo A=msgbox("请重新输入密码或登录花三千的博客http://hexun.com/6148713/default.html",4144,"密码不正确") >>d:\h3000\xsq.vbs
@echo end if >>d:\h3000\xsq.vbs
@echo next >>d:\h3000\xsq.vbs
@echo if x = %m% then >>d:\h3000\xsq.vbs
@echo A=msgbox("祝你开心",4144,"密码正确") >>d:\h3000\xsq.vbs
@echo else >>d:\h3000\xsq.vbs
@echo A=msgbox("今天到此为止!",4144,"对不起!") >>d:\h3000\xsq.vbs
@echo end if >>d:\h3000\xsq.vbs
@echo do until A = 2 >d:\h3000\naozhong.vbs
@echo S=inputbox("你希望在几分钟后提醒!","闹钟","5") >>d:\h3000\naozhong.vbs
@echo S=S*60000 >>d:\h3000\naozhong.vbs
@echo If S = 0 Then >>d:\h3000\naozhong.vbs
@echo exit do >>d:\h3000\naozhong.vbs
@echo End If >>d:\h3000\naozhong.vbs
@echo set ws=wscript.createobject("wscript.shell") >>d:\h3000\naozhong.vbs
@echo WScript.Sleep S >>d:\h3000\naozhong.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\naozhong.vbs
@echo BatRunner.run "cmd /c mplay32.exe /play /close C:\WINDOWS\Media\ringin.wav" >>d:\h3000\naozhong.vbs
@echo A=msgbox("闹钟时间到!是现在关机还是取消定时呢?",3,vbYesNo) >>d:\h3000\naozhong.vbs
@echo If A = 6 Then >>d:\h3000\naozhong.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\naozhong.vbs
@echo BatRunner.run "cmd /c shutdown /S /t 0 " >>d:\h3000\naozhong.vbs
@echo End If >>d:\h3000\naozhong.vbs
@echo loop >>d:\h3000\naozhong.vbs
@del /q "%USERPROFILE%\「开始」菜单\程序\启动\"*.*
@copy d:\h3000\xsq.vbs "%USERPROFILE%\「开始」菜单\程序\启动\"xsq.vbs
@echo A=inputbox("秘密被隐藏,想瞧瞧?请输入密码----","此地无银三百两","0") >d:\h3000\密藏.vbs
@echo If A = %m% Then >>d:\h3000\密藏.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\密藏.vbs
@echo BatRunner.run "cmd /c attrib -s -h *.*" >>d:\h3000\密藏.vbs
@echo else >>d:\h3000\密藏.vbs
@echo set BatRunner=createobject("wscript.shell") >>d:\h3000\密藏.vbs
@echo BatRunner.run "cmd /c attrib +s +h *.*" >>d:\h3000\密藏.vbs
@echo BatRunner.run "cmd /c attrib -s -h d:\h3000\密藏.vbs" >>d:\h3000\密藏.vbs
@echo A=msgbox("暂时无权查看,请登录花三千的博客http://hexun.com/6148713/default.html",4144,"密码不正确") >>d:\h3000\密藏.vbs
@echo end if >>d:\h3000\密藏.vbs
echo [InternetShortcut] >"%USERPROFILE%\桌面\花三千的博客.url
echo URL=http://hexun.com/6148713/default.html >>"%USERPROFILE%\桌面\花三千的博客.url
echo IconIndex=25 >>"%USERPROFILE%\桌面\花三千的博客.url
echo IconFile=C:\windows\system32\shell32.dll >>"%USERPROFILE%\桌面\花三千的博客.url
echo [InternetShortcut] >"%USERPROFILE%\桌面\闹钟.url
echo URL=d:\h3000\naozhong.vbs >>"%USERPROFILE%\桌面\闹钟.url
echo IconIndex=20 >>"%USERPROFILE%\桌面\闹钟.url
echo IconFile=C:\windows\system32\shell32.dll >>"%USERPROFILE%\桌面\闹钟.url
@start d:\h3000\gaozhi.vbs
花三千:
博客http://hexun.com/6148713/default.html
QQ:495055548 Mail:zma66826@126.com
[此贴子已经被作者于2007-9-14 22:33:23编辑过]