ฟอรั่มของบล็อก http://pssix.blogspot.com


Silent Mode Auto Install

Share
avatar
sak
PSsix Member Class II
PSsix Member Class II


จำนวนข้อความ : 34
ความนิยม : 0
เข้าร่วมเมื่อ : 26/11/2017

Silent Mode Auto Install

ตั้งหัวข้อ by sak on 10/12/17, 10:39 am

ให้ดาวโหลดโปรแกรม peid v0.95 แล้วสร้างโฟลเดอร์ขื่อ Plugin ขึ้นมา
แล้วนำ peid.exe เข้าไปเก็บไว้

Code:

;--------------------------------------start script---------------------------
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Date.au3>

Global $title_peid = 'PEiD v0.95'

;create gui
GUICreate("Advance Auto Installer v 2.0", 320, 179, 353, 292)
GUISetBkColor(0xC0DCC0)
$Progress1 = GUICtrlCreateProgress(9, 25, 302, 17)
$Button1 = GUICtrlCreateButton("Browse", 238, 62, 75, 25, $WS_GROUP)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Select program to install.")
$Input1 = GUICtrlCreateInput("", 82, 64, 155, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY), _
BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Input2 = GUICtrlCreateInput("", 104, 104, 115, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY), _
BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Button2 = GUICtrlCreateButton("Install", 124, 144, 75, 25, $WS_GROUP)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Auto install.")
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Exit", 300, 165, 21, 17, $SS_CENTER)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Close")
GUICtrlCreateLabel("ProgramName:", 10, 66, 70, 17)
GUICtrlCreateLabel("Parameters:", 45, 106, 60, 17)
$Label2 = GUICtrlCreateLabel("Progression", 130, 6, 59, 17, $SS_CENTER)
GUICtrlCreateLabel("by:child", 1, 145, 59, 17, $SS_CENTER)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label3 = GUICtrlCreateLabel("dd//mm//yyyy", 1, 162, 52, 17, $SS_CENTER)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetData($Label3, _NowDate())

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Label1
ExitLoop
Case $Button1 ;file browse and run plugin (PEiD) scan search type installer.
$executable = FileOpenDialog("Select a file to install", @DesktopDir & "|", _
"Program Setup (*.exe;*.msi)", 1 + 4)
If Not $executable Then ContinueLoop
Run(@ScriptDir & '\Plugin\PEiD.exe -hard ' & '"' & $executable & '"')
Sleep(150)
WinSetState($title_peid, '', @SW_HIDE)
$textstring = ControlGetText($title_peid, '', 'Edit1')
$idstring = ControlGetText($title_peid, '', 'Edit2')
While ($idstring = 'Scanning...') Or ($idstring = '')
$textstring = ControlGetText($title_peid, '', 'Edit1')
$idstring = ControlGetText($title_peid, '', 'Edit2')
WEnd
WinClose($title_peid)
; file path split for file.exe
Select
Case StringInStr($executable, 'exe')
$StringSp = StringSplit($Executable, '\')
If StringInStr($StringSp[2], 'exe') Then
$install = $StringSp[2]
ElseIf StringInStr($StringSp[3], 'exe') Then
$install = $StringSp[3]
ElseIf StringInStr($StringSp[4], 'exe') Then
$install = $StringSp[4]
ElseIf StringInStr($StringSp[5], 'exe') Then
$install = $StringSp[5]
ElseIf StringInStr($StringSp[6], 'exe') Then
$install = $StringSp[6]
ElseIf StringInStr($StringSp[7], 'exe') Then
$install = $StringSp[7]
ElseIf StringInStr($StringSp[8], 'exe') Then
$install = $StringSp[8]
EndIf
;scan type installer file.exe and parameters.
If StringInStr($idstring, 'Inno') Or StringInStr($idstring, 'Borland') Then
$parameters = '/sp- /verysilent'
ElseIf StringInStr($idstring, 'Nullsoft') Then
$parameters = '/S'
ElseIf StringInStr($idstring, 'Wise') Then
$parameters = '/s'
ElseIf StringInStr($idstring, 'InstallShield AFW') Then
$parameters = '/s /a /s /sms /f1"" /f2""'
ElseIf StringInStr($idstring, 'InstallShield 2003') Then
$parameters = '/v"/qn"'
ElseIf StringInStr($idstring, 'RAR SFX') Then
$parameters = '/s'
ElseIf StringInStr($textstring, 'kmplayer') Then
$parameters = '/S'
Else ;check error! if cann't found parameters
   If StringInStr($idstring, 'Nothing found [Overlay] *') Then
     MsgBox(48, "Error!" , "Cann't found Parameters" & @CRLF & "This's a program cann't run or install.")
     _reset()
     ContinueLoop
   EndIf
EndIf
GUICtrlSetData($Input1, $install)
GUICtrlSetData($Input2, $parameters)
GUICtrlSetState($Button2, $GUI_ENABLE)
;file path split for file.msi and parameters.
Case StringInStr($Executable, 'msi')
$StringSp = StringSplit($Executable, '\')
If StringInStr($StringSp[2], 'msi') Then
$install = $StringSp[2]
ElseIf StringInStr($StringSp[3], 'msi') Then
$install = $StringSp[3]
ElseIf StringInStr($StringSp[4], 'msi') Then
$install = $StringSp[4]
ElseIf StringInStr($StringSp[5], 'msi') Then
$install = $StringSp[5]
ElseIf StringInStr($StringSp[6], 'msi') Then
$install = $StringSp[6]
ElseIf StringInStr($StringSp[7], 'msi') Then
$install = $StringSp[7]
ElseIf StringInStr($StringSp[8], 'msi') Then
$install = $StringSp[8]
EndIf
GUICtrlSetData($Input1, 'msiexec /i' & ' ' & $install)
GUICtrlSetData($Input2, '/qn')
GUICtrlSetState($Button2, $GUI_ENABLE)
EndSelect
Case $Button2
GUICtrlSetState($Button2, $GUI_DISABLE)
Select ;run or installer program setup.exe
Case StringInStr($executable, 'exe')
Dim $pid

If StringInStr($textstring, 'kmplayer') Then
   $pid = Run($install & ' ' & $Parameters)
   Sleep(4000)
   Send("{Enter}")
Else
   $pid = Run($install & ' ' & $Parameters)
   Sleep(100)
EndIf

GUICtrlSetData($Label2, "Installing...")
GUICtrlSetColor($Label2, 0x0000FF)
Dim $i = 0
While ProcessExists($pid)
GUICtrlSetData($Progress1, $i)
$i = $i + 1
Sleep(20)
If $i > 100 Then $i = 0
If ProcessExists($pid) = 0 Then ExitLoop
WEnd
ProcessWaitClose($pid)
Sleep(500)
GUICtrlSetData($Progress1, 100)
Sleep(500)
GUICtrlSetData($Label2, "")
MsgBox(64, "" ,"Completed.")
_reset()
;run or installer program setup.msi
Case StringInStr($executable, 'msi')
GUICtrlSetState($Button2, $GUI_DISABLE)
$Parameters = '/qn'
Dim $pid
$pid = Run('msiexec /i' & ' ' & $install & ' ' & $Parameters)
Dim $i = 0
While ProcessExists($pid)
GUICtrlSetData($Progress1, $i)
$i = $i + 1
Sleep(20)
If $i > 100 Then $i = 0
If ProcessExists($pid) = 0 Then ExitLoop
WEnd
ProcessWaitClose($pid)
Sleep(500)
GUICtrlSetData($Progress1, 100)
Sleep(500)
MsgBox(64, "" ,"Completed.")
_reset()
EndSelect
EndSwitch
WEnd
;refresh function.
Func _reset()
GUICtrlSetData($Label2, "Progression")
GUICtrlSetColor($Label2, 0x000000)
GUICtrlSetData($Progress1, 0)
GUICtrlSetData($Input1, "")
GUICtrlSetData($Input2, "")
GUICtrlSetState($Button2, $GUI_DISABLE)
EndFunc
;--------------------------------------end script----------------------------

    เวลาขณะนี้ 21/09/18, 12:04 am