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


    请把txt、bat、inf打包压缩上传到网盘,我试试
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

这个文件是unicode编码试试用type来显示
  1. @echo off
  2. cd /d "%~dp0"
  3. setlocal enabledelayedexpansion
  4. (
  5. (for /f "tokens=1,3 delims= " %%a in ('findstr "\\" "ID.txt"') do (
  6.     if "%%b"=="" (
  7. set /p "=for /f "delims=" %%%%i in (inf.txt) do ("<nul
  8. echo;
  9. set /p "=type "%%%%i"|findstr /c:"%%a">nul&&echo %%%%i&&goto :id!nn!"<nul
  10. echo;
  11. set /p "=)"<nul
  12. echo;
  13.     ) else if "%%a"=="实例" (
  14. set /a n+=1
  15. set /a nn=!n!+1
  16. echo :id!n!
  17.     ) else (
  18. set /p "=for /f "delims=" %%%%i in (inf.txt) do ("<nul
  19. echo;
  20. set /p "=type "%%%%i"|findstr /c:"%%b">nul&&echo %%%%i&&goto :id!nn!"<nul
  21. echo;
  22. set /p "=)"<nul
  23. echo;
  24.     )
  25. ))
  26. set /a n+=1
  27. echo :id!n!
  28. )>ids.bat
  29. call ids.bat
复制代码

TOP

本帖最后由 yakeyun 于 2023-1-7 22:59 编辑

回复 16# Batcher


老大稍等下,我正在完善功能,完善后一起打包上传,到时候各位大佬可以看下还有没有更完美的方案,在其基础上继续修改。

测试包打包下载地址:
https://sanli.lanzoub.com/iqJsm0kdwd5e

TOP

本帖最后由 yakeyun 于 2023-1-8 09:56 编辑

最终代码如下,如果出现打不上的驱动,就直接将对应的驱动换到,也方便排除有问题或无用的驱动:
  1. @echo off
  2. cd /d "%~dp0"
  3. setlocal enabledelayedexpansion
  4. ::禁用指定ID的RAID硬件,并刷新硬件列表。
  5. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_88821043&REV_00\3&11583659&0&70"
  6. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  7. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_467F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  8. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_467F&SUBSYS_00008086&REV_00\3&11583659&0&70"
  9. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  10. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  11. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  12. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  13. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  14. cls
  15. ::==========================自动获取主板型号提取未打驱动ID到目录==========================
  16. pnputil /enum-devices /problem 28 /ids >.\ID.txt
  17. ::==========================自动获取主板型号提取未打驱动ID到目录==========================
  18. (
  19. (for /f "tokens=1,3 delims= " %%a in ('findstr "\\" "ID.txt"') do (
  20.     if "%%b"=="" (
  21. set /p "=for /f "delims=" %%%%i in ('findstr /s /m /c:"%%a" *.inf') do ("<nul
  22. echo;
  23. echo start /min "" "%SystemRoot%\system32\pnputil.exe" /subdirs  /add-driver "%~dp0%%%%i"  /install
  24. echo goto :id!nn!
  25. set /p "=)"<nul
  26. echo;
  27.     ) else if "%%a"=="实例" (
  28. set /a n+=1
  29. set /a nn=!n!+1
  30. echo :id!n!
  31.     ) else (
  32. set /p "=for /f "delims=" %%%%i in ('findstr /s /m /c:"%%b" *.inf') do ("<nul
  33. echo;
  34. echo  start /min "" "%SystemRoot%\system32\pnputil.exe" /subdirs  /add-driver "%~dp0%%%%i"  /install
  35. echo goto :id!nn!
  36. set /p "=)"<nul
  37. echo;
  38.     )
  39. ))
  40. set /a n+=1
  41. echo :id!n!
  42. )>ids.bat
  43. call ids.bat
  44. ::刷新硬件列表更新硬件状态
  45. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  46. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  47. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  48. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  49. cls
  50. exit
复制代码
测试包打包下载地址:
https://sanli.lanzoub.com/iqJsm0kdwd5e

TOP

本帖最后由 yakeyun 于 2023-1-8 09:53 编辑

回复 17# idwma


大佬的代码我明天测试下看看,这个需要借用我之前分享的"纯批处理写入映像到USB移动盘",制作的WIN TO GO 硬盘。
移动盘里面安装了一个影子系统软件,重启系统后所有的操作都还原了,所以测试一些驱动或者危险操作很方便。

[分享]Windows下拖放文件到纯批处理上给第三方磁盘分区装系统 - BAT求助&讨论 - 批处理之家 批处理_BAT脚本_PowerShell_VBS_CMD_DOS_Perl_Python - Powered by Discuz!  http://www.bathome.net/thread-63279-1-1.html


代码测试完毕,可以正常匹配到,通过显示的驱动信息可以看到,之前推断的是正确的,说明这个154KB驱动还是有些问题的。
进一步对2个版本的驱动文本进行对比,发现160KB的比154KB的版本要高,同时160KB的包含了154KB驱动的全部硬件信息,还多出一些额外的新硬件信息。
最终只需要将154KB文件淘汰处理,直接删除就可以解决问题。






TOP

本帖最后由 yakeyun 于 2023-1-9 18:41 编辑

回复 17# idwma


type这个代码更精准,之前打不上的已经可以打上了。应该是这个代码匹配了带*字符前缀的硬件ID。
测试视频:https://sanli.lanzoub.com/iiaIR0kk1uqd
测试包裹:https://sanli.lanzoub.com/iUi0u0kk54ej


修改后有2个版本:
一个是先把匹配的驱动文件输出到install.txt,然后再读取安装。
一个是一边匹配一边安装,感觉第二种速度更快,节省了安装等待时间。


成品代码如下:
  1. @echo off
  2. cd /d "%~dp0"
  3. mode con cols=50 lines=20
  4. setlocal enabledelayedexpansion
  5. ::禁用指定ID的RAID硬件,并刷新硬件列表。
  6. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_88821043&REV_00\3&11583659&0&70"
  7. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  8. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_467F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  9. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_467F&SUBSYS_00008086&REV_00\3&11583659&0&70"
  10. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  11. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  12. cls
  13. ::=========================提取驱动文件=========================
  14. for /f %%e in ('wmic cpu get name^ /value ^|find /i "intel"') do ((for /f "tokens=* delims=, " %%b in ('dir /a /s /b .\intels\*.inf ') do echo %%b)>"inf.txt")
  15. for /f %%a in ('wmic cpu get name^ /value ^|find /i "AMD"') do ((for /f "tokens=* delims=, " %%b in ('dir /a /s /b .\amds\*.inf ') do echo %%b)>"inf.txt")
  16. (for /f "tokens=* delims=, " %%b in ('dir /a /s /b .\Public\*.inf ') do echo %%b)>>"inf.txt"
  17. ::========================提取驱动ID信息=========================
  18. :run
  19. pnputil /enum-devices /problem 28 /ids >.\ID.txt
  20. for /f %%s in ('type "ID.TXT" ^|find "在系统上找不到任何设备"') do (goto END)
  21. ::======================通过ID匹配驱动安装驱动======================
  22. (
  23. (for /f "tokens=1,3 delims= " %%a in ('findstr "\\" "ID.txt"') do (
  24.     if "%%b"=="" (
  25. set /p "=for /f "delims=" %%%%i in (inf.txt) do ("<nul
  26. echo;
  27. set /p "=type "%%%%i"|findstr /c:"%%a">nul&&echo "%%%%i" >>install.txt&&goto :id!nn!"<nul
  28. echo;
  29. set /p "=)"<nul
  30. echo;
  31.     ) else if "%%a"=="实例" (
  32. set /a n+=1
  33. set /a nn=!n!+1
  34. echo :id!n!
  35.     ) else (
  36. set /p "=for /f "delims=" %%%%i in (inf.txt) do ("<nul
  37. echo;
  38. set /p "=type "%%%%i"|findstr /c:"%%b">nul&&echo "%%%%i" >>install.txt&&goto :id!nn!"<nul
  39. echo;
  40. set /p "=)"<nul
  41. echo;
  42.     )
  43. ))
  44. set /a n+=1
  45. echo :id!n!
  46. )>ids.bat
  47. call ids.bat
  48. (for /f %%i in (install.txt) do (
  49. start /min "" "%SystemRoot%\system32\pnputil.exe" /add-driver %%i /install
  50. ))
  51. if exist install.txt del install.txt
  52. ::刷新硬件列表更新硬件状态
  53. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  54. cls
  55. ECHO,1> NO1.DLL
  56. ::======================再次检测是否有硬件没有打上驱动======================
  57. if exist NO1.DLL (del NO1.DLL && call :run)
  58. ::=============================清理战场=============================
  59. :END
  60. IF EXIST INSTALL.TXT DEL INSTALL.TXT
  61. IF EXIST ID.TXT DEL ID.TXT
  62. IF EXIST INF.TXT DEL INF.TXT
  63. IF EXIST IDS.BAT DEL IDS.BAT
  64. IF EXIST NO1.DLL DEL NO1.DLL
  65. exit
复制代码
修改后的版本,边匹配边安装,感觉速度更快:
  1. @echo off
  2. cd /d "%~dp0"
  3. mode con cols=50 lines=20
  4. setlocal enabledelayedexpansion
  5. ::禁用指定ID的RAID硬件,并刷新硬件列表。
  6. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_88821043&REV_00\3&11583659&0&70"
  7. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  8. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_467F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  9. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_467F&SUBSYS_00008086&REV_00\3&11583659&0&70"
  10. call "%SystemRoot%\system32\pnputil.exe" /disable-device "PCI\VEN_8086&DEV_A77F&SUBSYS_86941043&REV_00\3&11583659&0&70"
  11. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  12. cls
  13. ::=========================提取驱动文件=========================
  14. for /f %%e in ('wmic cpu get name^ /value ^|find /i "intel"') do ((for /f "tokens=* delims=, " %%b in ('dir /a /s /b .\intels\*.inf ') do echo %%b)>"inf.txt")
  15. for /f %%a in ('wmic cpu get name^ /value ^|find /i "AMD"') do ((for /f "tokens=* delims=, " %%b in ('dir /a /s /b .\amds\*.inf ') do echo %%b)>"inf.txt")
  16. (for /f "tokens=* delims=, " %%b in ('dir /a /s /b .\Public\*.inf ') do echo %%b)>>"inf.txt"
  17. ::========================提取驱动ID信息=========================
  18. :run
  19. pnputil /enum-devices /problem 28 /ids >.\ID.txt
  20. for /f %%s in ('type "ID.TXT" ^|find "在系统上找不到任何设备"') do (goto END)
  21. ::======================通过ID匹配驱动安装驱动======================
  22. (
  23. (for /f "tokens=1,3 delims= " %%a in ('findstr "\\" "ID.txt"') do (
  24.     if "%%b"=="" (
  25. set /p "=for /f "delims=" %%%%i in (inf.txt) do ("<nul
  26. echo;
  27. set /p "=type "%%%%i"|findstr /c:"%%a">nul&&start /min "" "%SystemRoot%\system32\pnputil.exe" /add-driver "%%%%i" /install&&goto :id!nn!"<nul
  28. echo;
  29. set /p "=)"<nul
  30. echo;
  31.     ) else if "%%a"=="实例" (
  32. set /a n+=1
  33. set /a nn=!n!+1
  34. echo :id!n!
  35.     ) else (
  36. set /p "=for /f "delims=" %%%%i in (inf.txt) do ("<nul
  37. echo;
  38. set /p "=type "%%%%i"|findstr /c:"%%b">nul&&start /min "" "%SystemRoot%\system32\pnputil.exe" /add-driver "%%%%i" /install&&goto :id!nn!"<nul
  39. echo;
  40. set /p "=)"<nul
  41. echo;
  42.     )
  43. ))
  44. set /a n+=1
  45. echo :id!n!
  46. )>ids.bat
  47. call ids.bat
  48. ::刷新硬件列表更新硬件状态
  49. call "%SystemRoot%\system32\pnputil.exe" /scan-devices
  50. cls
  51. ECHO,1> NO1.DLL
  52. ::======================再次检测是否有硬件没有打上驱动======================
  53. if exist NO1.DLL (del NO1.DLL && call :run)
  54. ::=============================清理战场=============================
  55. :END
  56. IF EXIST INSTALL.TXT DEL INSTALL.TXT
  57. IF EXIST ID.TXT DEL ID.TXT
  58. IF EXIST INF.TXT DEL INF.TXT
  59. IF EXIST IDS.BAT DEL IDS.BAT
  60. IF EXIST NO1.DLL DEL NO1.DLL
  61. exit
复制代码

TOP

回复 21# yakeyun


dir /s /b /a-d  更适合我

TOP

返回列表