Board logo

标题: [特效代码] 批处理if语句中exist filename只能查本目录下的文件? [打印本页]

作者: qwe274208829    时间: 2012-8-16 23:46     标题: 批处理if语句中exist filename只能查本目录下的文件?

刚刚制作了这个简单的自动下载QQ脚本
  1. @echo off
  2. if not exist QQ.exe (goto and) else goto end
  3. :and
  4. start http://dl_dir.qq.com/qqfile/qd/QQ2012Beta3_QQProtect2.8.exe
  5. pause&&exit
  6. :end
  7. echo 已经安装
  8. pause
复制代码
这个脚本只能查出当前脚本目录
   请问才能把搜索范围到全部盘
作者: 狗屁不通    时间: 2012-8-17 01:04

本帖最后由 狗屁不通 于 2012-8-17 01:09 编辑
  1. @echo off &cls&@echo 搜索中&for /r c:\ %%i in (qq.exe) do if exist start http://dl_dir.qq.com/qqfile/qd/QQ2012Beta3_QQProtect2.8.exe %%i
复制代码


其中 c:\ 代表C盘  可以缩小范围使搜索更快。
作者: qwe274208829    时间: 2012-8-17 08:42


   think
作者: 狗屁不通    时间: 2012-8-17 16:30

本帖最后由 狗屁不通 于 2012-8-17 16:50 编辑

回复 3# qwe274208829

  1. cd\&tree c: /f | findstr " qq.exe" && echo 已经安装&pause&exit || echo 没有安装 &pause&start http://dl_dir.qq.com/qqfile/qd/QQ2012Beta3_QQProtect2.8.exe
复制代码


二楼的代码太烂了,换个吧
作者: CrLf    时间: 2012-8-17 16:46

回复 4# 狗屁不通


    可以不用 findstr:
  1. dir /s /a-d qq.exe>nul||echo 找不到 qq.exe
复制代码

作者: 狗屁不通    时间: 2012-8-17 16:55

回复 5# CrLf


    确实。。学习了dir竟然可以这么厉害




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2