标题: [文件操作] 菜鸟写的批处理,不知道错在哪 [打印本页]
作者: zhaodaijun 时间: 2010-2-5 21:42 标题: 菜鸟写的批处理,不知道错在哪
if not exist c:\windows\system32\control.exe goto next
echo %computername%于%date%%time%发现系统存在control.exe程序>>c:\%computername%.txt
@exit
:Next
if not exist c:\windows\system32\mstsc.exe
echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt
exit
前面一步能执行,不知道为什么后面的就执行不了咯。请高人解答,本人菜鸟不知道错在那里
作者: jcy0307 时间: 2010-2-5 21:53
- :Next
- if not exist c:\windows\system32\mstsc.exe
- echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt
- exit
复制代码
第二段执行不成功是因为你用IF 判断后没有给出命令
正确代码如下
- :Next
- if not exist c:\windows\system32\mstsc.exe exit
- echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt
- exit
复制代码
如果不存在c:\windows\system32\mstsc.exe 则退出
[ 本帖最后由 jcy0307 于 2010-2-5 21:54 编辑 ]
作者: slovent 时间: 2010-2-5 21:55
菜鸟回答- if not exist c:\windows\system32\control.exe goto next
- echo %computername%于%date%%time%发现系统存在control.exe程序>>c:\%computername%.txt
- @exit
-
- :Next
- REM 这里加个exit试试
- if not exist c:\windows\system32\mstsc.exe exit
- echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt
- exit
复制代码
作者: zhaodaijun 时间: 2010-2-5 22:05 标题: 回复 3楼 的帖子
不对,还是不能执行第2步。
作者: slovent 时间: 2010-2-5 22:27
那你要的是不是这样的:- if exist %windir%\system32\control.exe echo %computername%于%date%%time%发现系统存在control.exe程序>>c:\%computername%.txt
- if not exist %windir%\system32\mstsc.exe exit
- echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt&exit
复制代码
作者: sgaizxt001 时间: 2010-2-6 01:34
- if exist c:\windows\system32\control.exe (echo %computername%于%date%%time%发现系统存在control.exe程序>>c:\%computername%.txt)
- if exist c:\windows\system32\mstsc.exe (echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt)
- exit
复制代码
[ 本帖最后由 sgaizxt001 于 2010-2-6 01:37 编辑 ]
作者: yang871674823 时间: 2010-2-11 16:53 标题: 回复 3楼 的帖子
看你写的代码我脑袋差点没爆!~~汗!~~~
送你一计:
for %%a in (control.exe mstsc.exe) do if exist c:\windows\system32\%%a echo %computername%于%date%%time%发现系统存在%%a程序>>c:\%computername%.txt
一行完事~~
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |