本帖最后由 techon 于 2011-5-29 01:16 编辑
很感谢 fastslz 费心制作批处理程序,使驱动备份、还原变得如此简单轻松
楼上的代码还是会出问题。。。
因为这个inf文件后面有两行:
HKLM, Software\%CompanySubkey%\%ProductSubkey%\Files\CATALOG, CB00*.cat,, "CB00*.cat"
HKLM, Software\%CompanySubkey%\%ProductSubkey%\Files\CATALOG, CB00*.cat,, "CB00*.cat"
导致中途退出的是以上这两行
这个for /f 执行最后
%%L==Software\%CompanySubkey%\%ProductSubkey%\Files\CATALOG, CB00*.cat,, "CB00*.cat"
%%~nL==OemName==CATALOG, CB00*.cat,, "CB00*
保险的解决办法是:- for /f "tokens=1,2 delims==此处为一个TAB制表符 " %%k in ('type "%Systemroot%\Inf\%InfName%.inf"^|findstr /i Catalogfile') do set "OemName=%%~nl"
复制代码 或- for /f "tokens=1,2 delims==此处为一个TAB制表符 " %%k in ('type "%Systemroot%\Inf\%InfName%.inf"^|find /i "Catalogfile"') do set "OemName=%%~nl"
复制代码 inf 文件的格式比较宽松,很多东西想怎么写就怎么写
还有这样的呢。。。 不过目前还没发现第三方驱动使用这样的inf信息
CatalogFile.NTx86 = ndisrd86.cat
CatalogFile.NTAMD64 = ndisrd64.cat
也就微软这么用。。。。暂时可以忽略,或者考虑加个判断是x86还是 *64- ; -- NDISRD_M.INF --
- ;
- ; Based on Passsthru Miniport INF file
- ;
- ; Copyright (c) 2000-2009, NT Kernel Resources
-
- ; ----------------------------------------------------------------------
-
- [Version]
- signature = "$Windows NT$"
- Class = Net
- ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318}
- Provider = %Ntkr%
- DriverVer = 08/27/2009,3.00.7.1
- CatalogFile.NTx86 = ndisrd86.cat
- CatalogFile.NTAMD64 = ndisrd64.cat
-
- [ControlFlags]
- ExcludeFromSelect = nt_ndisrdmp
-
- [DestinationDirs]
- DefaultDestDir=12
- ; No files to copy
-
- [Manufacturer]
- %Ntkr% = NTKR,NTx86,NTia64,NTamd64
-
- ;For Win2K
-
- [NTKR]
- %NdisrdMP_Desc% = NdisrdMP.ndi, nt_ndisrdmp
-
- ;For WinXP and later
-
- [NTKR.NTx86]
- %NdisrdMP_Desc% = NdisrdMP.ndi, nt_ndisrdmp
-
- [NTKR.NTia64]
- %NdisrdMP_Desc% = NdisrdMP.ndi, nt_ndisrdmp
-
- [NTKR.NTamd64]
- %NdisrdMP_Desc% = NdisrdMP.ndi, nt_ndisrdmp
-
-
- [NdisrdMP.ndi]
- AddReg = NdisrdMP.ndi.AddReg
- Characteristics = 0x29 ;NCF_NOT_USER_REMOVABLE | NCF_VIRTUAL | NCF_HIDDEN
-
- [NdisrdMP.ndi.AddReg]
- HKR, Ndi, Service, 0, NdisrdMP
-
- [NdisrdMP.ndi.Services]
- AddService = NdisrdMP,0x2, NdisrdMP.AddService
-
-
- [NdisrdMP.AddService]
- ServiceType = 1 ;SERVICE_KERNEL_DRIVER
- StartType = 3 ;SERVICE_DEMAND_START
- ErrorControl = 1 ;SERVICE_ERROR_NORMAL
- ServiceBinary = %12%\ndisrd.sys
- AddReg = NdisrdMP.AddService.AddReg
-
-
- [NdisrdMP.AddService.AddReg]
- ; ----------------------------------------------------------------------
- ; Add any miniport-specific parameters here. These are params that your
- ; filter device is going to use.
- ;
- ;HKR, Parameters, ParameterName, 0x10000, "MultiSz", "Parameter", "Value"
- ;HKR, Parameters, ParameterName2, 0x10001, 4
-
- [Strings]
- Ntkr = "NTKR"
- ndisrdMP_Desc = "WinpkFilter Miniport"
-
- [SourceDisksNames]
- ;None
-
- [SourceDisksFiles]
- ;None
复制代码
|