集成驱动终极大法之自动实现 - Windows克隆封装技术 - 系统评测 - 天空竞技场
发新话题
打印

[转帖] 集成驱动终极大法之自动实现

集成驱动终极大法之自动实现

作者:fly
前两天看了仙乃日“集成驱动之终极大法!封装和安装皆适用的”
http://www.lucky8k.com/thread-39335-1-1.html
受益颇多,手动试了下,觉得比较麻烦
因此写了个自动的。程序没有进行过多的容错处理,因此在很多特殊情况下可能不能正常运行。makecab

压缩实在是慢,不要误认为是程序停止响应。因论坛对附件的限制不能上传编译好的exe(200多k)贴上au3

源码,用的上就自己编译

在仙乃日的建议和指点下将程序改了下,本人编程能力实在有限,只能处理按以下方式存放的驱动

c:\drivers\sound\realtek\hdrealtek\*.*(hdrealtek\不能再含目录)

c:\drivers\sound\realtek\rkac\*.*(rkac\不能再含目录)

c:\drivers\sound\adi\hdadi\*.*(hdadi\不能再含目录)

不能处理ati显卡驱动存放方式如:c:\drivers\vga\ati\*.inf\b123

#include <GUIConstants.au3>
#include <File.au3>
#NoTrayIcon
#Region ### START Koda GUI section ### Form=
HotKeySet("{Esc}", "quit")
Dim $ml, $aRecords, $FileName
$AForm1 = GUICreate("制作cab驱动测试版", 400, 300)
GUICtrlCreateLabel("将驱动程序分类放在一个空目录下", 50, 30)
$Label1 = GUICtrlCreateLabel("待处理驱动所在目录:", 25, 90, 120, 20)
$Input1 = GUICtrlCreateInput("", 145, 88, 180, 20)
$Label2 = GUICtrlCreateLabel("处理后驱动存放目录:", 25, 122, 120, 20)
$Input2 = GUICtrlCreateInput("", 145, 118, 180, 20)
$Button1 = GUICtrlCreateButton("打开", 330, 88, 40, 20)
$Button4 = GUICtrlCreateButton("打开", 330, 118, 40, 20)
$Button2 = GUICtrlCreateButton("开始", 100, 160, 60, 25)
$Button3 = GUICtrlCreateButton("退出", 200, 160, 60, 25)
GUICtrlCreateLabel("压缩过程中可用ESC键退出", 100, 240)
GUICtrlSetColor(-1, 0xff0000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button3
Exit
Case $Button1
$dir = FileSelectFolder("请选择驱动所在目录", "")
If Not @error Then
GUICtrlSetData($Input1, $dir)
EndIf
Case $Button4
$dir1 = FileSelectFolder("请选择驱动存放目录", "")
If Not @error Then
GUICtrlSetData($Input2, $dir1)
EndIf
Case $Button2
$path = GUICtrlRead($Input1)
$path1 = GUICtrlRead($Input2)
If $path = "" Then
MsgBox(0, "", "请选择驱动所在目录")
ContinueLoop
ElseIf $path1 = "" Then
MsgBox(0, "", "请选择驱动存放目录")
ContinueLoop
Else
GUICtrlSetState($Button2, $GUI_DISABLE)
GUICtrlSetState($Button3, $GUI_DISABLE)
EndIf
$FileList1 = _FileListToArray($path, "*", 2)
If @error = 4 Then
MsgBox(0, "", "文件夹中貌似没有文件")
Exit
EndIf
DrvIndexA()
seek($path)
ToolTip("")
FileMove(@WindowsDir & "\inf\drvindex1.inf", $path1 & "\drvindex.inf", 1)
GUICtrlSetState($Button2, $GUI_ENABLE)
GUICtrlSetState($Button3, $GUI_ENABLE)
MsgBox(0, "", "驱动处理完成")
EndSwitch
WEnd
Func DrvIndexA()
If FileExists(@WindowsDir & "\inf\drvindex1.inf") Then
FileDelete(@WindowsDir & "\inf\drvindex1.inf")
EndIf
_FileReadToArray(@WindowsDir & "\inf\drvindex.inf", $aRecords)
For $x = 1 To $aRecords[0]
If StringLeft(StringStripWS($aRecords[$x], 1), 1) <> "" And StringLeft(StringStripWS($aRecords[$x], 1), 1) <> ";" Then
If StringLeft(StringStripWS($aRecords[$x], 1), 1) = "[" Then
FileWriteLine(@WindowsDir & "\inf\drvindex1.inf", @CRLF & $aRecords[$x])
Else
FileWriteLine(@WindowsDir & "\inf\drvindex1.inf", $aRecords[$x])
EndIf
EndIf
Next
EndFunc ;==>DrvIndexA
Func seek($dir);from www.autoit.net.cn/pcbar
If StringRight($dir, 1) <> "\" Then $dir = $dir & "\" ;使路径以"\"结尾
$FileList2 = _FileListToArray($dir, "*", 2);把指定目录里的所有目录名(不含路径,不含子目录)装入到$FileList数组里去,
If UBound($FileList2) > 1 Then;如果指定目录下有目录存在……
For $i = 1 To $FileList2[0]
$FileList2[$i] = $dir & $FileList2[$i];把找到的目录名加上完整路径
$ml = $FileList2[$i]
$FileList3 = _FileListToArray($ml, "*", 1)
If $FileList3[0] >= 1 Then
$str = StringSplit($ml, "\", 1)
$FileName = $str[$str[0]]
drvindexB()
Inf()
ToolTip("正在压缩" & $FileName & ".cab,请稍候....", @DesktopWidth - 200, @DesktopHeight - 80, "请耐心等待,压缩时间较长", 1)
makecab()
EndIf
seek($FileList2[$i]);递归调用
Next
EndIf
EndFunc ;==>seek
Func drvindexB()
$CabFirst = IniRead(@WindowsDir & "\inf\drvindex1.inf", "Version", "CabFiles", "")
IniWrite(@WindowsDir & "\inf\drvindex1.inf", "Version", "CabFiles", $CabFirst & "," & $FileName)
IniWrite(@WindowsDir & "\inf\drvindex1.inf", "Cabs", $FileName, $FileName & ".cab")
FileWriteLine(@WindowsDir & "\inf\drvindex1.inf", @CRLF & "[" & $FileName & "]")
$FileList4 = _FileListToArray($ml, "*.*", 1)
For $i = 1 To $FileList4[0]
$str1 = StringSplit($FileList4[$i], ".", 1)
If $str1[2] <> "inf" Then
FileWriteLine(@WindowsDir & "\inf\drvindex1.inf", $FileList4[$i])
EndIf
Next
EndFunc ;==>drvindexB
Func Inf()
$InfList = _FileListToArray($ml, "*.inf", 1)
For $i = 1 To $InfList[0]
$infkey = IniReadSection($ml & "\" & $InfList[$i], "SourceDisksNames")
If @error = 1 Then
$infkey = IniReadSection($ml & "\" & $InfList[$i], "SourceDisksNames.x86")
IniWrite($ml & "\" & $InfList[$i], "SourceDisksNames.x86", $infkey[1][0], '"fly","' & $FileName & '.CAB",,"I386"')
Else
IniWrite($ml & "\" & $InfList[$i], "SourceDisksNames", $infkey[1][0], '"fly","' & $FileName & '.CAB",,"I386"')
EndIf
Next
EndFunc ;==>Inf
Func makecab()
If FileExists($ml & "\InfList") Then
FileDelete($ml & "\InfList")
EndIf
If FileExists($ml & "\FileList") Then
FileDelete($ml & "\FileList")
EndIf
$FileList5 = _FileListToArray($ml, "*.*", 1)
For $m = 1 To $FileList5[0]
$str2 = StringSplit($FileList5[$m], ".", 1)
If $str2[2] = "inf" Then
FileWriteLine($ml & "\InfList", $FileList5[$m])
Else
FileWriteLine($ml & "\FileList", $FileList5[$m])
EndIf
Next
FileChangeDir($ml & "\")
RunWait(@ComSpec & " /c makecab /D CompressionType=LZX /D CompressionMemory=21 /D MaxDiskSize=CDROM /F FileList" _
& " /D DiskDirectoryTemplate=.\ /D cabinetnametemplate=" & $FileName & ".cab", "", @SW_HIDE)
RunWait(@ComSpec & " /c makecab /D CompressionType=LZX /D CompressionMemory=21 /D MaxDiskSize=CDROM /F InfList" _
& " /D DiskDirectoryTemplate=.\ /D cabinetnametemplate=" & $FileName & "_Inf.cab", "", @SW_HIDE)
FileMove($ml & "\*.cab", $path1 & "\", 1)
FileDelete("setup.inf")
FileDelete("setup.rpt")
FileDelete("FileList")
FileDelete("InfList")
EndFunc ;==>makecab
Func quit()
FileDelete($ml & "\FileList")
FileDelete($ml & "\InfList")
FileDelete(@WindowsDir & "\inf\drvindex1.inf")
If ProcessExists("makecab.exe") Then
ProcessClose("makecab.exe")
EndIf
Exit
EndFunc ;==>quit

TOP

Windows克隆封装技术精华帖索引
Ghost系统封装教程及封装工具原理
http://www.lucky8k.com/thread-38845-1-2.html
万能Ghost系统制作教程
http://www.lucky8k.com/thread-38846-1-2.html
做母盘流程
http://www.lucky8k.com/thread-39263-1-2.html
一步步教你如何制作iso文件,也就是如何刻盘!
http://www.lucky8k.com/thread-39264-1-2.html
自己做的一个封装GHOST安装版XP系统的教程
http://www.lucky8k.com/thread-39265-1-2.html
最新万能GHOST系统制作教程(最新封装方式)
http://www.lucky8k.com/thread-39266-1-2.html
GhostXP系统制作简明封装教程
http://www.lucky8k.com/thread-39267-1-2.html
SATA硬盘使用GHOST技巧总结
http://www.lucky8k.com/thread-39268-1-2.html
封装工具sysprep中文版 英文版下载!
http://www.lucky8k.com/thread-39269-1-1.html
以S&R&S为例,谈一下封装及封装工具
http://www.lucky8k.com/thread-39316-1-1.html

TOP

发新话题