找回密码
 加入
搜索
查看: 4623|回复: 4

基于BC2的自动更新脚本

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

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-23 21:38 , Processed in 0.102773 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表