[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文件操作] 菜鸟写的批处理,不知道错在哪

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



前面一步能执行,不知道为什么后面的就执行不了咯。请高人解答,本人菜鸟不知道错在那里

  1. :Next
  2. if not exist c:\windows\system32\mstsc.exe
  3. echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt
  4. exit
复制代码
第二段执行不成功是因为你用IF 判断后没有给出命令
正确代码如下
  1. :Next
  2. if not exist c:\windows\system32\mstsc.exe exit
  3. echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt
  4. exit
复制代码

如果不存在c:\windows\system32\mstsc.exe 则退出

[ 本帖最后由 jcy0307 于 2010-2-5 21:54 编辑 ]

TOP

菜鸟回答
  1. if not exist c:\windows\system32\control.exe goto next
  2. echo %computername%于%date%%time%发现系统存在control.exe程序>>c:\%computername%.txt
  3. @exit
  4. :Next
  5. REM 这里加个exit试试
  6. if not exist c:\windows\system32\mstsc.exe exit
  7. echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt
  8. exit
复制代码

TOP

回复 3楼 的帖子

不对,还是不能执行第2步。

TOP

那你要的是不是这样的:
  1. if exist %windir%\system32\control.exe echo %computername%于%date%%time%发现系统存在control.exe程序>>c:\%computername%.txt
  2. if not exist %windir%\system32\mstsc.exe exit
  3. echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt&exit
复制代码

TOP

  1. if exist c:\windows\system32\control.exe  (echo %computername%于%date%%time%发现系统存在control.exe程序>>c:\%computername%.txt)
  2. if exist c:\windows\system32\mstsc.exe (echo %computername%于%date%%time%发现系统存在mstsc.exe程序>>c:\%computername%.txt)
  3. exit
复制代码

[ 本帖最后由 sgaizxt001 于 2010-2-6 01:37 编辑 ]

TOP

回复 3楼 的帖子

看你写的代码我脑袋差点没爆!~~汗!~~~
送你一计:
for %%a in (control.exe mstsc.exe) do if exist c:\windows\system32\%%a echo %computername%于%date%%time%发现系统存在%%a程序>>c:\%computername%.txt

一行完事~~

TOP

返回列表