标题: 【讨论】用一个批处理取得一个文件中的文件名
[打印本页]
作者: dalong
时间: 2007-6-22 08:06
标题: 【讨论】用一个批处理取得一个文件中的文件名
需一个批处理文件,能够读取所有盘符下的文件autorun.inf,并把这个文件中autorun=setup.exe或者open=setup.exe的setup.exe赋值给一个变量
一个哥们帮着写了一个,可是现实的不完全正确请看
-----------------------------------------------------------
@echo off
del %temp%\list.ttt 2>nul
call :do setup
call :do open
cls
echo 以下为26个盘符下autorun.inf文件中 setup=和open=后面的内容
echo *************************************************************************
type %temp%\list.ttt
echo *************************************************************************
echo 按任意键退出
pause>nul
:do
for %%I in (c d e f g h i j k l m n o p q r s t u v w x y z) Do (
for /f "tokens=1,2* delims==" %%i in ('find "%1" ^<%%I:\autorun.inf 2^>nul') do (
IF not "%%j"=="" echo %%j>>%temp%\list.ttt
)
)-----------------------------------------------------------
显示的是
------------------------------------
sxulolg.exe
打开(&O)
sxulolg.exe
1
sxulolg.exe
打开(&O)
sxulolg.exe
1
sxulolg.exe
打开(&O)
sxulolg.exe
1
----------------------------------------
autorun.inf的内容
-------------------------------------
[AutoRun]
open=sxulolg.exe
shell\open=打开(&O)
shell\open\Command=sxulolg.exe
shell\open\Default=1----------------------------------------------
请在帮忙改改
[
Last edited by dalong on 2007-6-22 at 08:09 AM ]
作者: youxi01
时间: 2007-6-22 08:33
仔细研究下 findstr 正则吧,相信你能找到 答案的
作者: dalong
时间: 2007-6-22 22:32
Quote: |
Originally posted by youxi01 at 2007-6-22 08:33 AM:
仔细研究下 findstr 正则吧,相信你能找到 答案的 |
|
冰冻三尺非一日之寒,我现在要用,只好求助大家帮忙了
作者: wudixin96
时间: 2007-6-22 22:55
for /f "tokens=1,2* delims==" %%i in (autorun.inf) do (
IF /i "%%i"=="autorun" echo %%j &pause & exit
IF /i "%%i"=="open" echo %%j &pause & exit
)
试试这样呢?
作者: flyinspace
时间: 2007-6-22 23:40
好象挑战系列已经有类似的提取了。。
里面也有路径的提取。
作者: dalong
时间: 2007-6-23 22:22
Quote: |
Originally posted by wudixin96 at 2007-6-22 10:55 PM:
for /f "tokens=1,2* delims==" %%i in (autorun.inf) do (
IF /i "%%i"=="autorun" echo %%j &pause & exit
IF /i "%%i"=="open" echo %%j &p ... |
|
能够正确的读取了,多谢了