forked from Bioruebe/UniExtract2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UniExtractUpdater.au3
55 lines (43 loc) · 2.01 KB
/
UniExtractUpdater.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=support\Icons\uniextract_exe.ico
#AutoIt3Wrapper_Res_Description=Update utility for Universal Extractor
#AutoIt3Wrapper_Res_Fileversion=1.0.0
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.14.1
Author: Bioruebe
Script Function:
Auto-updater for Universal Extractor
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
Const $sTitle = "Universal Extractor Updater"
Const $sUniExtract = @ScriptDir & "\UniExtract.exe"
If Not FileExists($sUniExtract) Then Exit MsgBox(16, $sTitle, "Universal Extractor main executable not found in current directory." & @CRLF & @CRLF & "Path is " & $sUniExtract)
If $cmdline[0] < 1 Then Exit ShellExecute($sUniExtract, "/update")
$OSArch = @OSArch = 'X64'? 'x64': 'x86'
If $cmdline[0] == 2 Then
_UpdateFFMPEG()
ElseIf $cmdline[1] == "/pluginst" Then
Exit ShellExecute($sUniExtract, "/plugins")
Else
If Not FileExists($cmdline[1]) Then Exit MsgBox(16, $sTitle, "Invalid update package passed to updater.")
_UpdateUniExtract()
EndIf
Func _UpdateUniExtract()
If Not ProcessWaitClose($sUniExtract, 10) Then Exit MsgBox(16, $sTitle, "Failed to close Universal Extractor. Please terminate the process manually and try again.")
$sCmd = @ScriptDir & '\bin\' & $OSArch & '\7z.exe x -y -xr!UniExtract.ini -o"' & @ScriptDir & '" "' & $cmdline[1] & '"'
RunWait($sCmd)
Sleep(100)
FileDelete($cmdline[1])
Run($sUniExtract & " /afterupdate")
EndFunc
Func _UpdateFFMPEG()
; Binaries
FileMove($cmdline[1] & "\bin\ffmpeg.exe", @ScriptDir & "\bin\" & $OSArch & "\ffmpeg.exe", 1)
FileMove($cmdline[1] & "\licenses\*", @ScriptDir & "\docs\FFmpeg\", 8+1)
DirRemove($cmdline[1], 1)
; License files
If $cmdline[2] <> 0 Then FileMove($cmdline[2], @ScriptDir & "\docs\FFmpeg\FFmpeg_license.html", 8 + 1)
Run($sUniExtract)
EndFunc