基于BC2的自动更新脚本
<p><span style="color: #000000">#NoTrayIcon</span><br />Dim $UpdateNow, $Refb, $RunError, $CodeTest<br />$SN = StringSplit(@ScriptName, ".")<br />$Section = $SN<br />$IniFile = @ScriptDir&Chr(92)&$Section&".ini"</p><p>If $CmdLine <> 0 Then<br /> $Section = $CmdLine<br />Else<br /> $Section = InputBox("提示", "请输入游戏名称", "", "", 1, 1, -1, -1)<br /> If @error Or $Section = '' Then Exit<br />EndIf</p><p>$g_szVersion = $Section<br />If WinExists('《'&$g_szVersion&'》') Then<br /> MsgBox(4160, '提示', '《'&$g_szVersion&'》更新已存在!', 3)<br /> Exit<br />EndIf<br />AutoItWinSetTitle('《'&$g_szVersion&'》')</p><p>$CodeTest = "OK"</p><p>$Images = IniRead($IniFile, $Section, "同步目录", "")</p><p>If $Images = "" Then<br /> While Not FileExists($Images) OR $Images = ""<br /> $Images = FileSelectFolder('请指定或输入《'&$Section&'》的同步目录所在位置。例如:<a href="file://Server/Share/'&$Section" target="_blank">\\Server\Share\'&$Section</a>, "", 4)<br /> If @error Then Exit 0<br /> If FileExists($Images) AND $Images <> "" Then IniWrite($IniFile, $Section, "同步目录", '"'&$Images&'"')<br /> WEnd<br />EndIf</p><p>$OldInfo = IniRead($IniFile, $Section, "同步信息", "")<br />$RunPath = IniRead($IniFile, $Section, "游戏目录", "")<br />$Run>If $RunPath <> "" AND FileExists($RunPath) Then SplashTextOn('《'&$g_szVersion&'》', '等待更新《'&$g_szVersion&'》......', -1, 24, 0, 0, 1, '', 18, 0)<br />$size = DirGetSize($Images, 1)<br />$time = FileGetTime($Images, 0, 1)<br />If $size = -1 OR $time = 1 Then<br /> $NewInfo = ''<br />ElseIf $size = 0 Then<br /> $NewInfo = ''<br />Else<br /> $NewInfo = StringReplace(($size+$size+$size)/($time*($size+$size)), "e-", "");这里会导至某些游戏验证慢。<br />EndIf<br />IniWrite($IniFile, $Section, "同步信息", '"'&$OldInfo&'"')</p><p><br />If $RunPath <> "" AND Not FileExists($RunPath) Then DirCreate($RunPath)<br />If $RunPath = "" OR $Run> While Not FileExists($RunPath) OR $RunPath = "" OR $Run> $Full> If @error Then<br /> $RunPath = FileSelectFolder('请指定或输入《'&$Section&'》文件夹所在位置,或新建文件夹。', "", 1+2+4)<br /> If @error Then Exit<br /> $Full> If @error Then<br /> $Run> If @error Then Exit<br /> $FN = StringSplit($RunName, ".")<br /> If $FN = 1 Then $Run> Else<br /> $FN = StringSplit($FullName, "\")<br /> $Run> EndIf<br /> Else<br /> $FN = StringSplit($FullName, "\")<br /> $Run> $RunPath = StringReplace($FullName, "\"&$FN[$FN], "")<br /> EndIf<br /> WEnd<br /> IniWrite($IniFile, $Section, "游戏目录", '"'&$RunPath&'"')<br /> IniWrite($IniFile, $Section, "执行文件", '"'&$RunName&'"')<br /> $Shortcut> If Not @error Then FileCreateShortcut( _<br /> @ScriptFullPath, _<br /> $ShortcutName, "", '"'&$Section&'"', "Make By Amu", $RunPath&Chr(92)&$RunName, "", "0")<br /> $UpdateNow = MsgBox(36,"提示!","是否立即运行更新?")<br /> If $UpdateNow = 7 Then Exit 0<br />EndIf<br />If Not FileExists($RunPath&Chr(92)&$RunName) AND $RunPath <> "" AND $Run> </p><p>If ( FileExists($Images) AND $NewInfo <> $OldInfo ) OR ( Not FileExists($RunPath&Chr(92)&$RunName) AND $RunPath <> "" AND $Run> ;安装BC2软件<br /> $BC2> </p><p> $FormPos = Int((@DesktopWidth-401)/2)&','&Int((@DesktopHeight-351)/2)&','&Int((@DesktopWidth-401)/2)+112&','&Int((@DesktopHeight-351)/2)+27&',1,0,96'<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmFileMove", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmFileCompare", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmFileCopy", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmFolderCreate", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmReadonly", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmOverwriteSysFile", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmMoveOverExisting", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfirmContentCompare", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "SyncInteractive", "REG_DWORD", "1")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ConfigMode", "REG_DWORD", "4")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "SyncRight", "REG_SZ", "0022224100")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "ShowOnStartup", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\Settings", "Recycle", "REG_DWORD", "0")<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\FolderViewer", "FormPos", "REG_SZ", $FormPos)<br /> RegWrite("HKCU\Software\Scooter Software\Beyond Compare\FolderViewer\Menu", "SyncRight", "REG_DWORD", "16834642")<br /> $Pid = -1<br /> If FileExists($BC2Name) AND $CodeTest = "OK" Then $Pid = Run($BC2Name&' /expandall "'&$Images&'" "'&$RunPath&'"', @TempDir )<br /> $Title = '正在更新《'&$g_szVersion&'》'<br /> AutoItSetOption("WinTitleMatchMode", 4)<br /> While ProcessExists($Pid) AND Not WinExists('同步预览', '')<br /> WinActivate("class> Send('+^!r')<br /> Sleep(100)<br /> WEnd<br /> SplashOff()<br /> While ProcessExists($Pid) AND WinExists('同步预览', '')<br /> If ControlCommand('同步预览', '', 'TButton3', "IsVisible", "") = 1 Then<br /> If ControlCommand('同步预览', '', 'TButton3', "IsEnabled", "") = 1 Then ControlClick('同步预览', '', 'TButton3')<br /> Sleep(100)<br /> If WinExists('同步到', '') Then<br /> WinSetTitle('同步到', '', $Title)<br /> $TitlePos = WinGetPos($Title, '')<br /> WinMove($Title, '', $TitlePos, $TitlePos, 399, 131 )<br /> ControlMove($Title, '', 'TBCCheckBox1', -13, 80, 400, 17)<br /> ControlSetText($Title, '', 'TBCCheckBox1', '注意!更新过程中请不要强行退出,否则不能正常进入游戏。')<br /> ControlHide($Title, '取消', 'TButton2')<br /> WinSetState("class> WinSetTitle("class> ExitLoop<br /> EndIf<br /> Else<br /> Sleep(100)<br /> ControlClick('同步预览', '取消', 'TButton2')<br /> ExitLoop<br /> EndIf<br /> WEnd<br /> While ProcessExists($Pid) AND WinExists($Title, '')<br /> If WinExists($Title, '无法') AND ControlCommand($Title, '', 'TButton2', "IsVisible", "") = 0 Then<br /> ControlShow($Title, '', 'TButton2')<br /> ControlSetText($Title, '', 'TBCCheckBox1', '更新过程中出现错误,可能无法正常运行游戏;请与网管联系。')<br /> EndIf<br /> If WinGetState("class> If ControlCommand($Title, "", "TBCCheckBox1", "IsChecked", "") = 1 Then _<br /> ControlCommand($Title, "", "TBCCheckBox1", "UnCheck", "")<br /> If WinExists($Title, '请求') AND $RunError <> 1 Then<br /> WinSetTitle( $Title, '请求', '已取消更新《'&$g_szVersion&'》' )<br /> $RunError = 1<br /> EndIf<br /> Sleep(500)<br /> WEnd<br /> ProcessClose($Pid)<br /> SplashOff()<br /> If $CodeTest = "OK" Then IniWrite($IniFile, $Section, "同步信息", '"'&$NewInfo&'"')</p><p> If $Refb = 1 Then<br /> $RefbFile = @TempDir&Chr(92)&Chr(Random(Asc("A"), Asc("Z"), 1))&'.tmp'<br /> IniWrite($RefbFile, "version", "signature", "$chicago$" )<br /> IniWrite($RefbFile, "version", "SetupClass", "BASE" )<br /> RunWait('rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 '&$RefbFile, @SystemDir, @SW_HIDE)<br /> If FileExists($RefbFile) Then FileDelete($RefbFile)<br /> EndIf</p><p> ;清除临时文件<br /> FileRecycleEmpty()<br /> RegDelete("HKCU\Software\Scooter Software")<br /> If FileExists($BC2Name) Then<br /> FileDelete($BC2Name)<br /> FileDelete(@TempDir&'\bc2.key')<br /> EndIf<br />EndIf<br />If $RunError = 1 Then Exit 1</p><p>;导入注册表<br />$RN = StringSplit($RunName, ".")<br />$RegFile = 'Path.dll'<br />If FileExists($RunPath&Chr(92)&$RegFile) Then RunWait('Regedit.exe -s "'&$RunPath&Chr(92)&$RegFile&'"', @SystemDir)<br />$RegFile = $RN&'.reg'<br />If FileExists($RunPath&Chr(92)&$RegFile) Then RunWait('Regedit.exe -s "'&$RunPath&Chr(92)&$RegFile&'"', @SystemDir)</p><p>;不运行游戏<br />If StringLower($CmdLine[$CmdLine]) = '-n' OR StringLower($CmdLine[$CmdLine]) = '-norun' OR $UpdateNow = 6 Then<br /> MsgBox(0, $g_szVersion, '《'&$g_szVersion&'》更新已完成', 1)<br /> Exit<br />EndIf</p><p>;运行游戏<br />If FileExists($RunPath&Chr(92)&$RunName) AND $RunPath <> "" AND $Run> </p><div>;自定义函数<br />Func _InstallBC2()<br /> $b = Chr(92)&Chr(Random(Asc("a"), Asc("z"), 1))<br /> For $i = 1 to Random(2, 7, 1)<br /> $b = $b&Chr(Random(Asc("a"), Asc("z"), 1))<br /> Next<br /> $b = @TempDir&$b&'.exe'<br /> FileInstall ("c:\bc2.exe", $b, 1)<br /> FileInstall ("c:\bc2.key", @TempDir&'\bc2.key', 1)<br /> return $b<br />EndFunc 正需要的资料谢谢!!沙发!~ 这个好像在哪里见过。 好强大 学习下 写的是个jb
页:
[1]