无忧启动论坛

标题: 【讨论】用一个批处理取得一个文件中的文件名 [打印本页]

作者: dalongx    时间: 2007-6-20 21:12
标题: 【讨论】用一个批处理取得一个文件中的文件名
急需一个批处理文件,能够读取所有盘符下的文件autorun.inf,并把这个文件中autorun=setup.exe中的setup.exe赋值给一个变量
在网上查了不少资料,可是不会改,请看

ipconfig /all >ipconfig.txt
if exist phyaddr.txt del phyaddr.txt
find "Physical Address" ipconfig.txt >phyaddr.txt
for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M
echo on
echo %Mac% >aa.txt
pause

这个就能取得并赋值给变量MAC,请高手给写写,急用,谢谢了

[ 本帖最后由 dalongx 于 2007-6-21 01:58 PM 编辑 ]
作者: wjh6088    时间: 2007-6-21 20:40

  1. @echo off
  2. del %temp%\list.ttt 2>nul
  3. 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 (
  4. for /f  "tokens=1,2* delims==" %%i in  ('find "setup"  ^<%%I:\autorun.inf 2^>nul') do (
  5. IF not "%%j"=="" echo %%j>>%temp%\list.ttt  
  6. )
  7. )
  8. cls
  9. echo 以下为26个盘符下autorun.inf文件中 setup=后面的内容
  10. echo *************************************************************************
  11. type %temp%\list.ttt
  12. echo *************************************************************************
  13. echo 按任意键退出
  14. pause>nul
复制代码

作者: dalongx    时间: 2007-6-21 22:15
多谢wjh6088 大哥的答案,我没有说说清楚,我发现有的盘符下的autorun.inf是这样的open=setup.exe字数变了,取得的就不完全正确了,这样改如何改呢?
作者: wjh6088    时间: 2007-6-22 00:03

  1. @echo off
  2. del %temp%\list.ttt 2>nul
  3. call :do setup
  4. call :do open
  5. cls
  6. echo 以下为26个盘符下autorun.inf文件中 setup=和open=后面的内容
  7. echo *************************************************************************
  8. type %temp%\list.ttt
  9. echo *************************************************************************
  10. echo 按任意键退出
  11. pause>nul

  12. :do
  13. 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 (
  14. for /f  "tokens=1,2* delims==" %%i in  ('find "%1"  ^<%%I:\autorun.inf 2^>nul') do (
  15. IF not "%%j"=="" echo %%j>>%temp%\list.ttt  
  16. )
  17. )
复制代码

作者: dalongx    时间: 2007-6-22 07:59
autorun.inf
---------------------------
[AutoRun]
open=sxulolg.exe
shell\open=打开(&O)
shell\open\Command=sxulolg.exe
shell\open\Default=1
shell\explore=资源管理器(&X)
-------------------------------------
显示的是
------------------------------------
sxulolg.exe  
打开(&O)  
sxulolg.exe  
1  
sxulolg.exe  
打开(&O)  
sxulolg.exe  
1  
sxulolg.exe  
打开(&O)  
sxulolg.exe  
1

----------------------------------------
请在帮忙改改

[ 本帖最后由 dalongx 于 2007-6-22 08:02 AM 编辑 ]
作者: wjh6088    时间: 2007-6-22 12:25
你想要的是哪一行啊 ,说不清楚怎么帮你!
作者: dalongx    时间: 2007-6-22 17:13
想得到文件autorun.inf文件中要运行的可执行文件名称

因为我这有几台机器,有的机器中的autorun.inf是open=sxulolg.exe我就想取变量=sxulolg.exe
有的机器中的autorun.inf是autorun=setup.exe我就想取变量=setup.exe

[ 本帖最后由 dalongx 于 2007-6-22 05:18 PM 编辑 ]
作者: lianjiang    时间: 2007-6-22 17:33
先好好学习如何提问。呵呵。否则既是浪费别人时间,也是浪费自己时间。
作者: dalongx    时间: 2007-6-22 20:03
:'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(
作者: dalongx    时间: 2007-6-28 22:49
问题已在别的论坛解决,在此对给我答复的各位表示感谢了:kiss:




欢迎光临 无忧启动论坛 (http://bbs.c3.wuyou.net/) Powered by Discuz! X3.3