*mr nerk asked me to create a smaller and cleaner version of the script.
here’s the updates:
The file size of the finished version is now 179kb.
Okai_Recorder now available for download
Okai_chat available as soon as nerk adds it to his dltxt (will show available as soon as this happens)
n7za.exe was recompiled and added directly to the movsq site for auto download so there’s no need to include n7za.exe with the compile
backing up of current install has been removed
About the script:
Some buddies of mine asked me to write a script for them that auto updates nFBA and the kaillera client. The outcome ended up being a simple exe that will install, check for updates, download updates, backup current install and launch nFBA.
In other words it’ll completely update and launch nFBA quicker than it’d take you to launch internet explorer and go to the website from a bookmark…
I’ve decided to post a brief tutorial on how you can compile your own exe to do this same task…
To compile this you’ll need AutoIt ver. 3 Exe Compiler
Autoit is what the whole script is written compiled and launched with. *note If you compile all the way to exe you will no longer need the autoit program itself, the exe includes everything it needs to launch the script. If you leave autoit installed you can launch from the .au3 file instead
copy the script posted at the bottom into a text file named updates.au3
once all that is done open “Compile script to .exe” in the autoit section of your start menu or if using the SciTE editor just hit ctrl + f7. (to decrease your filesize compile using autoit 3.2.0)
Global Const $GUI_EVENT_CLOSE = -3
Global Const $GUI_CHECKED = 1
Global Const $GUI_DISABLE = 128
If FileExists(@ScriptDir & "\7zDec.exe") Then
Else
InetGet("http://kaillera.movsq.net/install/7zDec.exe", @scriptdir & "\7zDec.exe", 1, 1)
EndIf
GUICreate("nFB Installer", 180, 170)
Opt("GUICoordMode",2) ;
$nFBA = GUICtrlCreateCheckBox ("nFBA", 20, 30, 85)
$kaillera = GUICtrlCreateCheckBox ("Kaillera Client", -1, 0)
$okaichat = GUICtrlCreateCheckBox ("Okai Chat", -1, 0)
$okairecord = GUICtrlCreateCheckBox ("Okai Record", -1, 0)
Opt("GUICoordMode",2) ;
$button_ok = GUICtrlCreateButton ("OK", -90, 10, 50)
$button_cancel = GUICtrlCreateButton ( "Cancel", 0, -1)
$source=_INetGetSource('http://kaillera.movsq.net/?dltxt')
$source=StringStripCR($source)
$source=StringSplit($source, chr(10))
$nfbaread = IniRead (@scriptdir & "
02.ini", "lastinstall", "nfba", "")
$kailleraread = IniRead (@scriptdir & "
02.ini", "lastinstall", "kaillera", "")
$okairecread = IniRead (@scriptdir & "
02.ini", "lastinstall", "okairec", "")
$okaichatread = IniRead (@scriptdir & "
02.ini", "lastinstall", "okaichat", "")
If $source[1] = $kailleraread Then
GUICtrlSetState ( $kaillera, $GUI_DISABLE )
Else
EndIf
If $source[2] = $okairecread Then
GUICtrlSetState ( $okairecord, $GUI_DISABLE )
Else
EndIf
If $source[3] = $nfbaread Then
GUICtrlSetState ( $nfba, $GUI_DISABLE )
Else
EndIf
If $source[4] = $okaichatread Then
GUICtrlSetState ( $okaichat, $GUI_DISABLE )
Else
EndIf
GUISetState ()
Opt("GUICoordMode",1) ;
GuiCtrlCreateLabel("Select Download:", 10, 10, 300, 12)
While 1
$msg = GUIGetMsg()
If $msg = $button_ok Then ExitLoop
If $msg = $button_cancel Then Exit 0
If $msg = $GUI_EVENT_CLOSE Then Exit 0
Wend
If GUICtrlRead($nFBA, 0) = $GUI_CHECKED then
okairead("nfba.7z", "nfba", $source[3])
Else
EndIf
If GUICtrlRead ($okairecord, 0) = $GUI_CHECKED Then
okairead("okai_recorder.7z", "okairec", $source[2])
Else
Endif
If GUICtrlRead ($okaichat, 0) = $GUI_CHECKED Then
okairead("okai_p2pchat.7z", "okaichat", $source[4])
Else
EndIf
If GUICtrlRead($kaillera, 0) = $GUI_CHECKED then
okairead("kailleraclient.dll", "kaillera", $source[1])
Else
EndIf
If FileExists(@ScriptDir & "
fba.7z") Then
filedelete(@ScriptDir & "
fba.7z")
Else
EndIf
If FileExists(@ScriptDir & "\okai_recorder.7z") Then
filedelete(@ScriptDir & "\okai_recorder.7z")
Else
EndIf
If FileExists(@ScriptDir & "
fba.exe") Then
Run("nfba.exe")
Exit
Else
Exit
EndIf
func okairead($7zfile, $type, $sourca)
$7zread = IniRead (@scriptdir & "
02.ini", "lastinstall", $type, "")
If $sourca = $7zread then
TrayTip("NFBA", "No Update Available" & @InetGetBytesRead & " Bytes", 10, 16)
Else
InetGet("http://kaillera.movsq.net/wip/" & $7zfile, $7zfile, 1, 1)
Iniwrite (@ScriptDir & "
02.ini", "lastinstall", $type, $sourca)
While @InetGetActive
TrayTip($7zfile, @InetGetBytesRead, 10, 16)
Sleep(250)
Wend
TrayTip($7zfile,"Finished", 10, 16 )
u7zip( $7zfile, @scriptDir, 123456 )
EndIf
EndFunc
Func u7zip($archive, $dest, $pass = "")
If $pass <> "" Then $pass = "-p" & '"' & $pass & '" '
RunWait(@ScriptDir &'\7zDec.exe' & ' e "' & $archive & '" ' & $pass & "-y -o" & '"' & $dest & '"')
EndFunc
;===============================================================================
;
; Function Name: _INetGetSource()
; Description: Gets the source from an URL without writing a temp file.
; Parameter(s): $s_URL = The URL of the site.
; Requirement(s): DllCall/Struct & WinInet.dll
; Return Value(s): On Success - Returns the source code.
; On Failure - 0 and sets @ERROR = 1
; Author(s): Wouter van Kesteren.
;
;===============================================================================
Func _INetGetSource($s_URL, $s_Header = '')
If StringLeft($s_URL, 7) <> 'http://' And StringLeft($s_URL, 8) <> 'https://' Then $s_URL = 'http://' & $s_URL
Local $h_DLL = DllOpen("wininet.dll")
Local $ai_IRF, $s_Buf = ''
Local $ai_IO = DllCall($h_DLL, 'int', 'InternetOpen', 'str', "AutoIt v3", 'int', 0, 'int', 0, 'int', 0, 'int', 0)
If @error Or $ai_IO[0] = 0 Then
DllClose($h_DLL)
SetError(1)
Return ""
EndIf
Local $ai_IOU = DllCall($h_DLL, 'int', 'InternetOpenUrl', 'int', $ai_IO[0], 'str', $s_URL, 'str', $s_Header, 'int', StringLen($s_Header), 'int', 0x80000000, 'int', 0)
If @error Or $ai_IOU[0] = 0 Then
DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
DllClose($h_DLL)
SetError(1)
Return ""
EndIf
Local $v_Struct = DllStructCreate('udword')
DllStructSetData($v_Struct, 1, 1)
While DllStructGetData($v_Struct, 1) <> 0
$ai_IRF = DllCall($h_DLL, 'int', 'InternetReadFile', 'int', $ai_IOU[0], 'str', '', 'int', 256, 'ptr', DllStructGetPtr($v_Struct))
$s_Buf &= StringLeft($ai_IRF[2], DllStructGetData($v_Struct, 1))
WEnd
DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IOU[0])
DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
DllClose($h_DLL)
Return $s_Buf
EndFunc ;==>_INetGetSource