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

[文本处理] [已解决]求助批处理FOR提取数据加入skip就无效

这边需要对GPU-Z获取到的显卡信息做提取,如果加入skip命令后,就无法获取到数据,删除后就可以正常提取。
请问在不提取数据到新文档的前提下,有办法可以直接通过代码调整获取第二块显卡的数据信息吗?
  1. @echo off & setlocal EnableDelayedExpansion
  2. @cd /d "%~dp0"
  3. for /f "skip=54 tokens=*" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do echo %%a
  4. pause
  5. for /f "skip=54 delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set subsysid=%%c)
  6. echo %subsysid%
  7. pause>nul
  8. echo.
  9. pause
复制代码
文件提取地址:https://sanli.lanzoub.com/ieqqF07y3u9e

整合后的版本:
  1. @echo off & setlocal EnableDelayedExpansion
  2. @cd /d "%~dp0"
  3. if exist gpuz.xml (del gpuz.xml)
  4. if exist ")" (del ")")
  5. call GPU-Z.exe -dump GPUZ.xml
  6. set n=1
  7. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<gpuname>"') do (
  8.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set gpuname!n!=%%c
  9.   set /a n+=1
  10.   )
  11.   set n=1
  12. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<vendorid>"') do (
  13.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set vendorid!n!=%%c
  14.   set /a n+=1
  15.   )
  16.   set n=1
  17. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<deviceid>"') do (
  18.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set deviceid!n!=%%c
  19.   set /a n+=1
  20.   )
  21.   set n=1
  22. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<subvendorid>"') do (
  23.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set subvendorid!n!=%%c
  24.   set /a n+=1
  25.   )
  26.   set n=1
  27. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do (
  28.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set subsysid!n!=%%c
  29.   set /a n+=1
  30.   )
  31. echo 显卡一:%gpuname1% %vendorid1% %deviceid1%-%subvendorid1% %subsysid1%
  32. echo 显卡二:%gpuname2% %vendorid2% %deviceid2%-%subvendorid2% %subsysid2%
  33. set gpuname=%gpuname1%
  34. set vendorid=%vendorid1%
  35. set deviceid=%deviceid1%
  36. set subvendorid=%subvendorid1%
  37. set subsysid=%subsysid1%
  38. set installs=1
  39. :installDrive
  40. ::10400  Comet Lake GT2
  41. if "%gpuname%"=="Intel Xe" (start /min "" ".\DG1\DVrun.bat" & Goto End)
  42. if "%gpuname%"=="Arc Alchemist" (start /min "" ".\A380\DVrun.bat" & Goto End)
  43. if "%gpuname%"=="Alder Lake" (start /min "" ".\Intel_Video\DvRun.bat" & Goto End)
  44. if "%vendorid%"=="8086" (start /min "" ".\Intel_Video\DvRun.bat" & Goto End)
  45. if "%vendorid%"=="1002" (echo 我是AMD显卡 & start /min "" ".\AMD580\DvRun.bat" & Goto End)
  46. if "%gpuname%"=="GK208"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  47. if "%gpuname%"=="GK208B"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  48. if "%gpuname%"=="GF119"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  49. if "%gpuname%"=="GF108"  (echo 我是NVIDIAGT730显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  50. if "%gpuname%"=="GK208B"  (echo 我是NVIDIAGT730显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  51. ::T600   T400   T1000
  52. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB1-10DE 1488"  (echo 我是NVIDIAT600显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  53. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB2-10DE 1489"  (echo 我是NVIDIAT400显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  54. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB0-103C 12DB"  (echo 我是NVIDIAT1000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  55. if "%gpuname%"=="GA106"  (echo 我是NVIDIAA2000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  56. if "%gpuname%"=="GP106"  (echo 我是NVIDIAP2000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  57. ::P1000    P620    P400
  58. if "%gpuname%"=="GP107"  (echo 我是NVIDIAP620显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  59. if "%vendorid%"=="10DE" (echo 我是NVIDIA游戏显卡 & start /min "" ".\NV3050\DvRun.bat" & Goto End)
  60. :End
  61. if !installs! EQU 2 (call :Qlzc)
  62. if not !gpuname2! EQU "" (
  63. set gpuname=%gpuname2%
  64. set vendorid=%vendorid2%
  65. set deviceid=%deviceid2%
  66. set subvendorid=%subvendorid2%
  67. set subsysid=%subsysid2%
  68. set /a installs=!installs!+1
  69. call :installDrive
  70. )
  71. :Qlzc
  72. if exist gpuz.xml (del gpuz.xml)
  73. if exist GPUZ2.xml (del GPUZ2.xml)
  74. if exist ")" (del ")")
  75. exit
复制代码

TOP

回复 4# flashercs

谢谢大佬,可以正常取值。这个代码主要是用来安装显卡驱动的,由于技嘉主板CPU带核显的情况下,会显示2个显卡选项,所以之前的代码默认只打了核显驱动,没有打独显。
我这边用创建第三方文件的方法,也得到了解决。后面我看下把您的和我的合并一下一起处理。
  1. @echo off & setlocal EnableDelayedExpansion
  2. @cd /d "%~dp0"
  3. if exist gpuz.xml (del gpuz.xml)
  4. if exist ")" (del ")")
  5. call GPU-Z.exe -dump GPUZ.xml
  6. for /f %%a in ('type "GPUZ.xml" ^|find /c /i "<cardname>Microsoft </cardname>"') do set "nums=%%a"
  7. if %nums% EQU 1 (call :Cari)
  8. for /f "skip=1 tokens=1 delims=:" %%a in ('type "GPUZ.xml" ^|findstr /n "<cardname>Microsoft </cardname>"') do set "kas=%%a" & set /a ka2=!kas!-3
  9. echo %ka2%
  10. :Cari
  11. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<gpuname>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set gpuname=%%c)
  12. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<vendorid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set vendorid=%%c)
  13. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<deviceid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set deviceid=%%c)
  14. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<subvendorid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set subvendorid=%%c)
  15. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set subsysid=%%c)
  16. echo %vendorid% %deviceid%-%subvendorid% %subsysid%
  17. echo %gpuname%
  18. set Cars=1
  19. :installDrive
  20. ::10400  Comet Lake GT2
  21. if "%gpuname%"=="Intel Xe" (start /min "" ".\DG1\DVrun.bat" & Goto End)
  22. if "%gpuname%"=="Arc Alchemist" (start /min "" ".\A380\DVrun.bat" & Goto End)
  23. if "%gpuname%"=="Alder Lake" (start /min "" ".\Intel_Video\DvRun.bat" & Goto End)
  24. if "%vendorid%"=="8086" (start /min "" ".\Intel_Video\DvRun.bat" & Goto End)
  25. if "%vendorid%"=="1002" (echo 我是AMD显卡 & start /min "" ".\AMD580\DvRun.bat" & Goto End)
  26. if "%gpuname%"=="GK208"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  27. if "%gpuname%"=="GK208B"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  28. if "%gpuname%"=="GF119"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  29. if "%gpuname%"=="GF108"  (echo 我是NVIDIAGT730显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  30. if "%gpuname%"=="GK208B"  (echo 我是NVIDIAGT730显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  31. ::T600   T400   T1000
  32. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB1-10DE 1488"  (echo 我是NVIDIAT600显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  33. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB2-10DE 1489"  (echo 我是NVIDIAT400显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  34. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB0-103C 12DB"  (echo 我是NVIDIAT1000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  35. if "%gpuname%"=="GA106"  (echo 我是NVIDIAA2000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  36. if "%gpuname%"=="GP106"  (echo 我是NVIDIAP2000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  37. ::P1000    P620    P400
  38. if "%gpuname%"=="GP107"  (echo 我是NVIDIAP620显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  39. if "%vendorid%"=="10DE" (echo 我是NVIDIA游戏显卡 & start /min "" ".\NV3050\DvRun.bat" & Goto End)
  40. :End
  41. if !Cars! EQU 2 (call :Qlzc)
  42. if !nums! EQU 2 (call :Carii)
  43. :Qlzc
  44. if exist gpuz.xml (del gpuz.xml)
  45. if exist GPUZ2.xml (del GPUZ2.xml)
  46. if exist ")" (del ")")
  47. exit
  48. :Carii
  49. (for /f "tokens=*" %%n in (GPUZ.xml) do (
  50.    set /a m+=1
  51.    if !m! LEQ !ka2! (echo %%n)
  52. )) >GPUZ2.xml
  53. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ2.xml" ^|find "<gpuname>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set gpuname=%%c)
  54. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ2.xml" ^|find "<vendorid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set vendorid=%%c)
  55. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ2.xml" ^|find "<deviceid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set deviceid=%%c)
  56. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ2.xml" ^|find "<subvendorid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set subvendorid=%%c)
  57. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ2.xml" ^|find "<subsysid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set subsysid=%%c)
  58. echo %vendorid% %deviceid%-%subvendorid% %subsysid%
  59. echo %gpuname%
  60. set /a Cars=!Cars!+1
  61. call :installDrive
复制代码

TOP

  1. @echo off
  2. @cd /d "%~dp0"
  3. if exist gpuz.xml (del gpuz.xml)
  4. if exist ")" (del ")")
  5. call GPU-Z.exe -dump GPUZ.xml
  6. setlocal EnableDelayedExpansion
  7. set n=1
  8. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<gpuname>"') do (
  9.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set gpuname!n!=%%c
  10.   set /a n+=1
  11.   )
  12.   set n=1
  13. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<vendorid>"') do (
  14.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set vendorid!n!=%%c
  15.   set /a n+=1
  16.   )
  17.   set n=1
  18. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<deviceid>"') do (
  19.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set deviceid!n!=%%c
  20.   set /a n+=1
  21.   )
  22.   set n=1
  23. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<subvendorid>"') do (
  24.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set subvendorid!n!=%%c
  25.   set /a n+=1
  26.   )
  27.   set n=1
  28. for /f "tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do (
  29.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set subsysid!n!=%%c
  30.   set /a n+=1
  31.   )
  32. echo %vendorid1% %deviceid1%-%subvendorid1% %subsysid1%
  33. echo %vendorid2% %deviceid2%-%subvendorid2% %subsysid2%
复制代码
1

评分人数

微信:flashercs
QQ:49908356

TOP

回复 2# flashercs


54行之前是第一个显卡的数据信息,54行以后是第二个显卡的数据。
已知第一个显卡的现在需要把两个显卡的信息分别获取出来。
完整代码如下:
  1. @echo off
  2. @cd /d "%~dp0"
  3. if exist gpuz.xml (del gpuz.xml)
  4. if exist ")" (del ")")
  5. call GPU-Z.exe -dump GPUZ.xml
  6. setlocal EnableDelayedExpansion
  7. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<gpuname>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set gpuname=%%c)
  8. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<vendorid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set vendorid=%%c)
  9. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<deviceid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set deviceid=%%c)
  10. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<subvendorid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set subvendorid=%%c)
  11. for /f "delims=^> tokens=1,*" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do (for /f "delims=^< tokens=1,*" %%c in ("%%b") do set subsysid=%%c)
  12. echo %vendorid% %deviceid%-%subvendorid% %subsysid%
  13. echo %gpuname%
  14. ::10400  Comet Lake GT2
  15. if "%gpuname%"=="Intel Xe" (start /min "" ".\DG1\DVrun.bat" & Goto End)
  16. if "%gpuname%"=="Arc Alchemist" (start /min "" ".\A380\DVrun.bat" & Goto End)
  17. if "%gpuname%"=="Alder Lake" (start /min "" ".\Intel_Video\DvRun.bat" & Goto End)
  18. if "%vendorid%"=="8086" (start /min "" ".\Intel_Video\DvRun.bat" & Goto End)
  19. if "%vendorid%"=="1002" (echo 我是AMD显卡 & start /min "" ".\AMD580\DvRun.bat" & Goto End)
  20. if "%gpuname%"=="GK208"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  21. if "%gpuname%"=="GK208B"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  22. if "%gpuname%"=="GF119"  (echo 我是NVIDIAGT710显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  23. if "%gpuname%"=="GF108"  (echo 我是NVIDIAGT730显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  24. if "%gpuname%"=="GK208B"  (echo 我是NVIDIAGT730显卡 & start /min "" ".\NV710\DvRun.bat" & Goto End)
  25. ::T600   T400   T1000
  26. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB1-10DE 1488"  (echo 我是NVIDIAT600显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  27. if "%vendorid% %deviceid%-%subvendorid% %subsysid%"=="10DE 1FB2-10DE 1489"  (echo 我是NVIDIAT400显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  28. if "%gpuname%"=="GA106"  (echo 我是NVIDIAA2000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  29. if "%gpuname%"=="GP106"  (echo 我是NVIDIAP2000显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  30. ::P1000    P620    P400
  31. if "%gpuname%"=="GP107"  (echo 我是NVIDIAP620显卡 & start /min "" ".\NVT400\DvRun.bat" & Goto End)
  32. if "%vendorid%"=="10DE" (echo 我是NVIDIA游戏显卡 & start /min "" ".\NV3050\DvRun.bat" & Goto End)
  33. :End
  34. if exist gpuz.xml (del gpuz.xml)
  35. if exist ")" (del ")")
  36. exit
复制代码

TOP

  1. @echo off & setlocal EnableDelayedExpansion
  2. @cd /d "%~dp0"
  3. for /f "skip=1 tokens=*" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do echo %%a
  4. pause
  5. for /f "skip=1 tokens=1,* delims=>" %%a in ('type "GPUZ.xml" ^|find "<subsysid>"') do (
  6.   for /f "tokens=1,* delims=<" %%c in ("%%b") do set subsysid=%%c
  7. )
  8. echo %subsysid%
  9. pause>nul
  10. echo.
  11. pause
复制代码
微信:flashercs
QQ:49908356

TOP

返回列表