|
#Region AutoIt3Wrapper 预编译参数(常用参数)
#AutoIt3Wrapper_Icon= ;图标,支持EXE,DLL,ICO
#AutoIt3Wrapper_OutFile= ;输出文件名
#AutoIt3Wrapper_OutFile_Type=exe ;文件类型
#AutoIt3Wrapper_Compression=4 ;压缩等级
#AutoIt3Wrapper_UseUPX=y ;使用压缩
#AutoIt3Wrapper_Res_Comment= ;注释
#AutoIt3Wrapper_Res_Description= ;详细信息
#AutoIt3Wrapper_Res_FileVersion= ;文件版本
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=p ;自动更新版本
#AutoIt3Wrapper_Res_LegalCopyright= ;版权
#AutoIt3Wrapper_Change2CUI=N ;修改输出的程序为CUI(控制台程序)
;#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% ;自定义资源段
;#AutoIt3Wrapper_Run_Tidy= ;脚本整理
;#AutoIt3Wrapper_Run_Obfuscator= ;代码迷惑
;#AutoIt3Wrapper_Run_AU3Check= ;语法检查
;#AutoIt3Wrapper_Run_Before= ;运行前
;#AutoIt3Wrapper_Run_After= ;运行后
#EndRegion AutoIt3Wrapper 预编译参数(常用参数)
#cs ____________________________________
Au3 版本:
脚本作者:
Email:
QQ/TM:
脚本版本:
脚本功能:
#ce _______________脚本开始_________________
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=1.ico
#AutoIt3Wrapper_OutFile=科宏U盘启动盘制作工具.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=QQ:215272447
#AutoIt3Wrapper_Res_Description=Kehong USB System 2011
#AutoIt3Wrapper_Res_FileVersion=8.0.0.2011
#AutoIt3Wrapper_Res_LegalCopyright=@copyright]#AutoIt3Wrapper_Res_LegalCopyright=@copyright 2011
#AutoIt3Wrapper_Res_Field=CompanyName|科宏电脑科技
#AutoIt3Wrapper_Res_Field=程序设计|飞天怪龙
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <ProgressConstants.au3>
#include <GuiImageList.au3>
#include <Process.au3>
#Region ### START Koda GUI section ### Form=
Dim $Dll
Dim $usb1
Global $DwptW = @TempDir & '\DsptW.eXe'
Global $ShowDrive = @TempDir & '\ShowDrive.eXe'
Global $Part = @TempDir & '\Part.Txt'
Global $GhostIni = @TempDir & '\Ghost.InI'
If FileExists($GhostIni) Then FileDelete($GhostIni)
FileInstall('ShowDrive.Vxd', $ShowDrive, 1)
RunWait($ShowDrive & ' /S', '', @SW_HIDE)
FileDelete($ShowDrive)
FileInstall('DsptW.Vxd', $DwptW, 1)
If FileExists($Part) Then FileDelete($Part)
RunWait(@ComSpec & ' /C ' & $DwptW & ' 0 /L >' & $Part, '', @SW_HIDE)
$SerailNumber = StringMid(FileReadLine($Part, 3), 59)
FileDelete($Part)
For $i = 1 To 26
RunWait(@ComSpec & ' /C ' & $DwptW & ' ' & $i & ' /Find:All /GhostStyle >>' & $Part, '', @SW_HIDE)
If StringInStr(FileRead($Part), 'Error') Then ExitLoop
Next
FileDelete($DwptW)
Dim $v
_FileReadToArray($Part, $v)
FileWrite($GhostIni, '[HardDisk]' & @CRLF)
For $i = 1 To $v[0]
$ReadLine = FileReadLine($Part, $i)
If StringInStr($ReadLine, 'Error') Then ExitLoop
If Not StringInStr($ReadLine, 'No.') And StringInStr($ReadLine, ':') Then
$GhostStr = StringMid($ReadLine, 6, 2) & '=' & StringMid($ReadLine, 1, 3)
If StringMid($GhostStr, 1, 1) = 1 And StringMid($ReadLine, 6, 2) = ' ' Then
FileWriteLine($GhostIni, StringReplace($GhostStr & 'C:', ' ', ''))
Else
FileWriteLine($GhostIni, $GhostStr)
EndIf
ExitLoop
EndIf
Next
For $i = 1 To $v[0]
$ReadLine = FileReadLine($Part, $i)
If StringInStr($ReadLine, 'Error') Then ExitLoop
If Not StringInStr($ReadLine, 'No.') And StringInStr($ReadLine, ':') Then
$GhostStr = StringMid($ReadLine, 6, 2) & '=' & StringMid($ReadLine, 1, 3)
If StringMid($ReadLine, 6, 2) <> '' And Not StringInStr($GhostStr, '1:1') Then FileWriteLine($GhostIni, $GhostStr)
EndIf
Next
FileDelete($Part)
_FileReadToArray($GhostIni, $v)
For $i = 2 To $v[0]
$ReadLine = StringLeft(FileReadLine($GhostIni, $i), 3)
If StringLeft($ReadLine, 1) = 1 Then
ExitLoop
EndIf
Next
$Var = IniReadSection($GhostIni, 'HardDisk')
If @error Then
MsgBox(262144, '', '出错了啦! 当前目录找不到 Ghost.InI 文件.')
Else
For $i = 1 To $Var[0][0]
$GetLastP = StringMid($Var[$i][0], 1, 1)
If StringInStr($GetLastP, 'H') Then $GetLastP = StringMid($Var[$i + 1][0], 1, 1)
If $GetLastP <> 1 Then
ExitLoop
EndIf
Next
EndIf
$i = 1
$Str = "CDEFGHIJKLMNOPQRSTUVWXYZ"
While $i <= 24
$Str1 = StringLeft($Str, $i)
$Dirve = StringRight($Str1, 1)
$Var = DriveGetType($Dirve & ":\")
If FileExists($Dirve & ":\") Then
If $Var = "REMOVABLE" Then
$Dirve1 = $Dirve & ":"
EndIf
If $Var <> "REMOVABLE" Then
$Dirve1 = ""
EndIf
EndIf
$i = $i + 1
WEnd
ini()
$usbhdd = IniRead($GhostIni, "USB", "name", "请插入U盘")
If $Dirve1 <> "" Then
$usbhdd1 = $Dirve1 & "名称:" & $usbhdd
EndIf
If $Dirve1 = "" Then
$usbhdd1 = "请插入U盘再运行本程序!"
MsgBox(64, "", "你没有插入U盘请插入U盘再运行本程序!")
Exit
EndIf
FileInstall("SkinCrafterDll.dll", @TempDir & "\SkinCrafterDll.dll", 1)
FileInstall("vista.skf", @TempDir & "\vista.skf", 1)
$Form1 = GUICreate("欢迎您使用科宏U盘启动盘制作工具", 395, 405, -1, -1)
_SkinGUI(@TempDir & "\SkinCrafterDll.dll", @TempDir & "\vista.skf", $Form1)
FileInstall("usb-PE.bmp", @TempDir & "\usb-PE.bmp", 1)
$Pic1 = GUICtrlCreatePic(@TempDir & "\usb-PE.bmp", 0, 0, 395, 90)
$Label1 = GUICtrlCreateLabel("选择要制作的U盘", 24, 138, 90, 20)
$Combo1 = GUICtrlCreateCombo($usbhdd1, 125, 136, 240, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Labelzip = GUICtrlCreateLabel("选择U盘启动格式", 24, 108, 90, 20)
$Combo2 = GUICtrlCreateCombo("", 125, 106, 240, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "USB-HDD|USB-ZIP", "USB-HDD")
$ListView1 = GUICtrlCreateListView("分区|序号|文件系统|已用容量|剩余容量|总容量(GB)", 24, 160, 345, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 35)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 35)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 5, 80)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 0, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 1, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 2, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 3, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 4, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 5, 2)
$z = 0
_GUICtrlListView_DeleteAllItems($ListView1)
$read = IniReadSection($GhostIni, "HardDisk")
If @error Then
MsgBox(64, "", "错误")
EndIf
If Not @error Then
For $i = 1 To $read[0][0]
$fjxt = DriveGetFileSystem($read[$i][0])
$zrl = Round(DriveSpaceTotal($read[$i][0]) / 1024, 2)
$syrl = Round(DriveSpaceFree($read[$i][0]) / 1024, 2)
$usrl = Round($zrl - $syrl, 2)
GUICtrlCreateListViewItem($read[$i][0], $ListView1)
_GUICtrlListView_AddSubItem($ListView1, $z, $read[$i][1], 1, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $fjxt, 2, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $syrl, 4, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $zrl, 5, $z + 1)
_GUICtrlListView_AddSubItem($ListView1, $z, $usrl, 3, $z + 1)
$z += 1
Next
EndIf
_GUICtrlListView_SetItemSelected($ListView1, $read[0][0] - 1)
GUICtrlCreateGroup("科宏提醒您", 24, 260, 350, 55)
GUICtrlCreateLabel("本程序制作成的U盘启动盘具有三防特性:防毒﹑防删﹑防格", 32, 280, 340, 15)
GUICtrlCreateLabel("运行本程序,请关闭安全软件,谢谢您的合作,祝您成功!", 34, 295, 335, 15)
$Button3 = GUICtrlCreateButton("开始制作(&S)", 30, 363, 90, 30)
$Button5 = GUICtrlCreateButton("还原U盘(&U)", 157, 363, 90, 30)
$ZT = GUICtrlCreateLabel("当前状态:等待用户确认设置开始制作...", 24, 330, 380, 20)
$pro = GUICtrlCreateProgress(24, 345, 350, 8, $PBS_SMOOTH)
If $Dirve1 = "" Then
GUICtrlSetState($Button3, $GUI_DISABLE)
EndIf
$Button4 = GUICtrlCreateButton("退出", 280, 363, 90, 30)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button4
quit()
Case $GUI_EVENT_CLOSE
quit()
Case $Button3
GUICtrlSetState($Button3, $GUI_DISABLE)
GUICtrlSetState($Button4, $GUI_DISABLE)
GUICtrlSetState($Button5, $GUI_DISABLE)
$ZIP = GUICtrlRead($Combo2)
If $ZIP = "USB-HDD" Then
$usb1 = ""
EndIf
If $ZIP = "USB-ZIP" Then
$usb1 = " --ZIP"
EndIf
$ZZUSB = GUICtrlRead($Combo1)
$ZZUSBHDD = StringLeft($ZZUSB, 2)
$HDFB = IniRead($GhostIni, "HardDisk", $ZZUSBHDD, "2:1")
$HDFB2 = StringLeft($HDFB, 1)
$HDFB1 = $HDFB2 - 1
GUICtrlSetData($pro, 10)
$ask = MsgBox(64 + 4, "提示", "你选择的了将" & $ZZUSB & "制作成可启动U盘" & @CRLF & @CRLF & "要确定开始制作,请点击“是”,否则点击“否”")
If $ask = 6 Then
GUICtrlSetData($ZT, "当前状态:正在准备程序必须数据中,请稍候...")
FileInstall("fbinst.exe", @WindowsDir & "\fbinst.exe", 1)
;RunWait(@ComSpec & " /c " & @WindowsDir&"\fbinst (hd"&$HDFB1&")"&"format --raw", @ScriptDir, @SW_HIDE)
RunWait(@WindowsDir & "\fbinst (hd" & $HDFB1 & ")" & " format --raw --force", @WindowsDir, @SW_HIDE)
GUICtrlSetData($pro, 20)
;RunWait(@ComSpec & " /c " & @WindowsDir&"\fbinst (hd"&$HDFB1&")"&"format --extended 125m --force --fat32 --align --primary 8m",@ScriptDir, @SW_HIDE)
RunWait(@WindowsDir & "\fbinst (hd" & $HDFB1 & ")" & " format --extended 90m --force" & $usb1 & " --fat32 --align --primary 8m", @WindowsDir, @SW_HIDE)
GUICtrlSetData($ZT, "当前状态:正在将引导程序写入U盘中,请稍候...")
GUICtrlSetData($pro, 40)
Sleep(1000)
GUICtrlSetData($ZT, "当前状态:正在准备U盘PE数据和必备文件中,请稍候...")
FileInstall("amwin.fba", @WindowsDir & "\abc.fba", 1)
GUICtrlSetData($pro, 60)
GUICtrlSetData($ZT, "当前状态:正在将PE维护系统数据写入U盘中,请稍候...")
;RunWait(@ComSpec & " /c " & @WindowsDir&"\fbinst (hd"&$HDFB1&")"&"load "[email=&@WindowsDir&]&@WindowsDir&"\abc.fba",@ScriptDir, @SW_HIDE)
RunWait(@WindowsDir & "\fbinst (hd" & $HDFB1 & ")" & " load " & @WindowsDir & "\abc.fba", @WindowsDir, @SW_HIDE)
GUICtrlSetData($pro, 90)
FileDelete(@WindowsDir & "\fbinst.exe")
FileDelete(@WindowsDir & "\abc.fba")
Sleep(1000)
GUICtrlSetData($pro, 100)
GUICtrlSetData($ZT, "当前状态:所有任务全部完成!")
MsgBox(64, "恭喜", "科宏U盘启动盘制作成功")
quit()
EndIf
If $ask = 7 Then
GUICtrlSetState($Button3, $GUI_ENABLE)
GUICtrlSetState($Button4, $GUI_ENABLE)
GUICtrlSetState($Button5, $GUI_ENABLE)
GUICtrlSetData($pro, 0)
EndIf
Case $Button5
$ZZUSB = GUICtrlRead($Combo1)
$ZZUSBHDD = StringLeft($ZZUSB, 2)
$HDFB = IniRead($GhostIni, "HardDisk", $ZZUSBHDD, "2:1")
$HDFB2 = StringLeft($HDFB, 1)
$HDFB1 = $HDFB2 - 1
GUICtrlSetState($Button3, $GUI_DISABLE)
GUICtrlSetState($Button4, $GUI_DISABLE)
GUICtrlSetState($Button5, $GUI_DISABLE)
$ask1 = MsgBox(64 + 4, "提示", "你选择的了将" & $ZZUSB & "U盘重置到默认状态," &@CRLF & @CRLF & "要确定重置U盘,请点击“是”,否则点击“否”")
If $ask1 = 6 Then
GUICtrlSetData($ZT, "当前状态:正在重置U盘中,请稍候...")
FileInstall("fbinst.exe", @WindowsDir & "\fbinst.exe", 1)
RunWait(@WindowsDir & "\fbinst (hd" & $HDFB1 & ")" & " format --raw --force", @WindowsDir, @SW_HIDE)
GUICtrlSetData($pro, 100)
Sleep(1000)
MsgBox(64, "提示", "重置U盘状态成功!")
GUICtrlSetData($ZT, "当前状态:等待用户确认设置开始制作...")
GUICtrlSetData($pro, 0)
GUICtrlSetState($Button3, $GUI_ENABLE)
GUICtrlSetState($Button4, $GUI_ENABLE)
GUICtrlSetState($Button5, $GUI_ENABLE)
EndIf
If $ask1 = 7 Then
GUICtrlSetState($Button3, $GUI_ENABLE)
GUICtrlSetState($Button4, $GUI_ENABLE)
GUICtrlSetState($Button5, $GUI_ENABLE)
GUICtrlSetData($pro, 0)
EndIf
EndSwitch
WEnd
Func ini()
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_diskdrive")
For $objItem In $colItems
IniWrite($GhostIni, $objItem.interfacetype, "Name", $objItem.caption)
$num = StringSplit($objItem.PNPDeviceID, "\")
$ii = UBound($num)
$ii = $ii - 1
$number = String($num[$ii])
IniWrite($GhostIni, $objItem.interfacetype, "ID", $number)
Next
EndFunc ;==>ini
Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
$Dll = DllOpen($SkincrafterDll)
DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1")
DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25)
DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc ;==>_SkinGUI
Func quit()
GUISetState(@SW_HIDE)
DllCall($Dll, "int:cdecl", "DeInitDecoration")
DllCall($Dll, "int:cdecl", "RemoveSkin")
DllClose($Dll)
FileDelete(@TempDir & "\SkinCrafterDll.dll")
FileDelete(@TempDir & "\vista.skf")
FileDelete($GhostIni)
FileDelete($DwptW)
FileDelete($ShowDrive)
FileDelete(@TempDir & "\usb-PE.bmp")
Exit
EndFunc ;==>quit
这样试试 |
|