|
vk
中级用户
  
积分 218
发帖 86
注册 2006-8-10
状态 离线
|
『楼 主』:
自己编的一个简单批处理文件 看看到底哪里出错了
使用 LLM 解释/回答一下
@echo off
net share c$ /del
net share d$ /del
net share e$ /del
net share ADMIN$ /del
net share windows$ /del
if not errorlevel 0 goto no
if not errorlevel 1 goto ok
:no
echo 操作失败!>>no.txt
no.txt
del no.txt
:ok
echo 操作成功!>>ok.txt
ok.txt
del ok.txt
运行后如果不成功它会先跳到:no 这然后跳到:ok
怎么才能让它 如果不成功就跳到:no
为什么操作不成功它会跳到:ok这里?
请高人指点!
|
|
2006-8-10 13:07 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
呵呵,你这个当然在OK的时候就执行OK标签里的语句了,如果不成功,NO和OK标签里的内容都要执行,批处理是按照逐步执行的顺序来完成的,试试下面的
@echo off
net share c$ /del
net share d$ /del
net share e$ /del
net share ADMIN$ /del
net share windows$ /del
if not errorlevel 0 goto no
if not errorlevel 1 goto ok
:no
echo 操作失败!>>no.txt
no.txt
del no.txt
goto end
:ok
echo 操作成功!>>ok.txt
ok.txt
del ok.txt
:end
OR
@echo off
net share c$ /del
net share d$ /del
net share e$ /del
net share ADMIN$ /del
net share windows$ /del
if not errorlevel 0 goto no
if not errorlevel 1 goto ok
:no
echo 操作失败!>>no.txt
no.txt
del no.txt
goto :eof
:ok
echo 操作成功!>>ok.txt
ok.txt
del ok.txt
|
|
2006-8-10 13:25 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
|
2006-8-10 14:27 |
|
|
vk
中级用户
  
积分 218
发帖 86
注册 2006-8-10
状态 离线
|
|
2006-8-10 18:37 |
|
|
iaide007
初级用户
 
积分 36
发帖 12
注册 2006-9-8
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
呵。直接加exit 也行
@echo off
net share c$ /del
net share d$ /del
net share e$ /del
net share ADMIN$ /del
net share windows$ /del
if not errorlevel 0 goto no
if not errorlevel 1 goto ok
:no
echo 操作失败!>>no.txt
no.txt
del no.txt
exit
:ok
echo 操作成功!>>ok.txt
ok.txt
del ok.txt
exit
|

QQ群名称:◥◣批处理时代◢◤
QQ群号码:6702314 |
|
2006-9-10 17:26 |
|
|
bigeyes
新手上路

积分 18
发帖 8
注册 2006-9-8
状态 离线
|
|
2006-9-12 10:28 |
|
|
IceCrack
中级用户
   DOS之友
积分 332
发帖 168
注册 2005-10-6 来自 天涯
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
好好看看三楼的链接吧!对你应该有帮助的
|

测试环境: windows xp pro sp2 高手是这样炼成的:C:\WINDOWS\Help\ntcmds.chm |
|
2006-9-12 11:33 |
|