Board logo

标题: 帮忙写个条件开机批处 [打印本页]

作者: lucifer0     时间: 2007-3-18 13:38    标题: 帮忙写个条件开机批处

我自己写了一个批处内容如下:
@echo off
if not exist h:\aaa.txt shutdown -s -f -t 0
H盘为U盘,只要建个aaa.txt就可以实现必须要U盘才能开机.
但是只在开机的时候检测一次,有没有可以在系统运行中不断检测的?(既一拔掉U盘就关机)
作者: jvgame     时间: 2007-3-18 14:59    标题: 你就循环运行这个bat就ok拉

你就循环运行这个bat就ok拉
作者: nzisisco     时间: 2007-3-18 18:06
汗 你怎么知道H盘是别人的U盘
作者: lucifer0     时间: 2007-3-18 23:36
2楼,我知道要循环运行啊,但不知道怎么实现啊!可以详细的写个出来吗?让大家学习啊...
作者: xycoordinate     时间: 2007-3-19 00:27
@echo off
if not exist h:\aaa.txt shutdown -s -f -t 0

你把这个批处理做个定时任务,不就OK了!
作者: chengmo     时间: 2007-3-19 01:15
这个比较有意思。。。

还可以在aaa.txt里面写上自已的密码哦,,不就可以知道是不是自已的还是别人的了吗

可以用SLEEP.

也可以用:@echo Wscript.Sleep Wscript.Arguments(0) * 1000>Delay.vbs
Delay.vbs 60
del Delay.vbs

这一段VBS,那个60是60秒,,可以修改,

要做到后台运行可以用:Set shell = Wscript.createobject("wscript.shell")

a = shell.run ("你的批处理文件名",0)


这一段VBS

[ Last edited by chengmo on 2007-3-18 at 12:25 PM ]
作者: slore     时间: 2007-3-19 02:27
@echo off
:loop
if not exist h:\aaa.txt shutdown -s -f -t 0
goto loop
作者: chengmo     时间: 2007-3-19 03:12


  Quote:
Originally posted by slore at 2007-3-18 01:27 PM:
@echo off
:loop
if not exist h:\aaa.txt shutdown -s -f -t 0
goto loop

这个太占资源了吧
作者: lucifer0     时间: 2007-3-19 08:10
首先谢谢6楼和7楼.....7楼的代码如果可以有时间间隔运行就更好!
作者: chengmo     时间: 2007-3-20 07:35
@echo of
:start
if not exist l:\aaa.txt shutdown -s -f -t 0
@echo Wscript.Sleep Wscript.Arguments(0) * 1000>Delay.vbs
Delay.vbs 5
del Delay.vbs
goto start


这样可以吗?

[ Last edited by chengmo on 2007-3-28 at 12:23 PM ]
作者: chengmo     时间: 2007-3-29 01:24
这个我在我电脑上面用了一下,可以哦,呵呵
作者: zh159     时间: 2007-3-29 05:12


  Quote:
Originally posted by chengmo at 2007-3-19 18:35:
@echo off
:start
if not exist l:\aaa.txt shutdown -s -f -t 0
@echo Wscript.Sleep Wscript.Arguments(0) * 1000>Delay.vbs
Delay.vbs 5
del Delay.vbs
goto start


这样可以吗?

[  ...

建立、删除VBS罗嗦了,改一下:
@echo off
echo Wscript.Sleep Wscript.Arguments(0) * 1000>Delay.vbs
:start
if not exist l:\aaa.txt shutdown -s -f -t 0
if exist Delay.vbs (Delay.vbs 5) else exit
goto start
如果需要停止,直接删除Delay.vbs就退出bat
作者: lucifer0     时间: 2007-4-9 04:38
谢谢,chengmo,zh159...可以了哦.....呵呵.....
作者: htysm     时间: 2007-4-10 03:44
@echo off
start /min
:star_
dir /a/b l:\aaa.txt || shutdown -s -f -t 0
ping 127.1 -n 30>nul 2>nul
goto star_