$Path1 = @ScriptDir & "\Launcher"
$Path2 = "http://site.com/launcher/Launcher.ini"
$Path3 = "http://site.com/launcher/patchinfo.txt"
$InetGet1 = InetGet($Path2, $Path1 & "\Launcher2.ini", 1+2)
If $InetGet1 = 0 Then
Switch MsgBox(21, "Пре-лаунчер", "Произошла ошибка при загрузке" & @CRLF & $Path2)
Case 4
_Restart()
Case 2
Exit
EndSwitch
EndIf
$Config1 = IniRead($Path1 & "\Launcher.ini", "Launcher", "PatchNum", "")
$Config2 = IniRead($Path1 & "\Launcher2.ini", "Launcher", "PatchNum", "")
If $Config1 < $Config2 Then
$InetGet2 = InetGet($Path3, $Path1 & "\patchinfo.txt", 1+2)
If $InetGet2 = 0 Then
Switch MsgBox(21, "Пре-лаунчер", "Произошла ошибка при загрузке" & @CRLF & $Path3)
Case 4
_Restart()
Case 2
Exit
EndSwitch
EndIf
$Config3 = IniRead($Path1 & "\patchinfo.txt", "patch_" & $Config1, "from", "")
IniWrite($Path1 & "\Launcher.ini", "Launcher", "LocalGame", $Config3)
;_FO_FileDirReName($Path1 & "\Launcher2.ini", "Launcher.ini", 1, 1, 0)
Run(@ScriptDir & "\launcher.exe")
EndIf
Func _FO_FileDirReName($sSource, $sNewName, $iFlag = 0, $DelAttrib = 0, $iDir = -1)
Local $i, $n, $sName, $sPath, $sTmpPath
If Not $sNewName Then Return SetError(2, 0, 0)
If StringRegExp($sNewName, '[\\/:*?"<>|]') Then Return SetError(5, 0, 0) ; (???) Индикатором служит FileMove/DirMove, но если отключить то FileMove будет поддерживать маски
If Not FileExists($sSource) Then Return SetError(3, 0, 0)
$n = StringInStr($sSource, '\', 0, -1)
$sPath = StringLeft($sSource, $n)
$sName = StringTrimLeft($sSource, $n)
If $iDir = -1 Then $iDir = StringInStr(FileGetAttrib($sSource), 'D')
$n = 0
If $sName = $sNewName Then
If $sName == $sNewName Then Return SetError(4, 0, 0)
$i = 0
Do
$i += 1
$sTmpPath = $sPath & '$#@_' & $i & '.tmp'
Until Not FileExists($sTmpPath)
If $iDir Then
If DirMove($sSource, $sTmpPath) Then $n = DirMove($sTmpPath, $sPath & $sNewName)
Else
If FileMove($sSource, $sTmpPath) Then $n = FileMove($sTmpPath, $sPath & $sNewName)
EndIf
Else
If $iDir Then
If FileExists($sPath & $sNewName) Then
If $iFlag Then
If $DelAttrib Then FileSetAttrib($sPath & $sNewName, "-RST", 1)
If StringInStr(FileGetAttrib($sPath & $sNewName), 'D') Then
If DirRemove($sPath & $sNewName, 1) Then $n = DirMove($sSource, $sPath & $sNewName)
Else
If FileDelete($sPath & $sNewName) Then $n = DirMove($sSource, $sPath & $sNewName)
EndIf
EndIf
Else
$n = DirMove($sSource, $sPath & $sNewName)
EndIf
Else
If FileExists($sPath & $sNewName) Then
If $iFlag Then
If $DelAttrib Then FileSetAttrib($sPath & $sNewName, "-RST", 1)
If StringInStr(FileGetAttrib($sPath & $sNewName), 'D') Then
If DirRemove($sPath & $sNewName, 1) Then $n = FileMove($sSource, $sPath & $sNewName)
Else
$n = FileMove($sSource, $sPath & $sNewName, $iFlag)
EndIf
EndIf
Else
$n = FileMove($sSource, $sPath & $sNewName)
EndIf
EndIf
EndIf
SetError(Not $n, 0, $n)
EndFunc ;==>_FO_FileDirReName
; http://autoit-script.ru/index.php/topic,309.msg2812.html#msg2812
; CreatoR
Func _Restart()
Local $sAutoIt_File = @TempDir & "\~Au3_ScriptRestart_TempFile.au3"
Local $sRunLine, $sScript_Content, $hFile
$sRunLine = @ScriptFullPath
If Not @Compiled Then $sRunLine = @AutoItExe & ' /AutoIt3ExecuteScript ""' & $sRunLine & '""'
If $CmdLine[0] > 0 Then $sRunLine &= ' ' & $CmdLineRaw
$sScript_Content &= '#NoTrayIcon' & @CRLF & _
'While ProcessExists(' & @AutoItPID & ')' & @CRLF & _
' Sleep(10)' & @CRLF & _
'WEnd' & @CRLF & _
'Run("' & $sRunLine & '")' & @CRLF & _
'FileDelete(@ScriptFullPath)' & @CRLF
$hFile = FileOpen($sAutoIt_File, 2)
FileWrite($hFile, $sScript_Content)
FileClose($hFile)
Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sAutoIt_File & '"', @ScriptDir, @SW_HIDE)
Sleep(1000)
Exit
EndFunc