#include Func _webDownloader($sSourceURL, $sTargetName, $sVisibleName, $sTargetDir = @TempDir, $bProgressOff = True, $iEndMsgTime = 2000, $sDownloaderTitle = "Downloader") ; Declare some general vars Local $iMBbytes = 1048576 ; If the target directory doesn't exist -> create the dir If Not FileExists($sTargetDir) Then DirCreate($sTargetDir) ; Get download and target info Local $sTargetPath = $sTargetDir & "\" & $sTargetName Local $iFileSize = InetGetSize($sSourceURL) Local $hFileDownload = InetGet($sSourceURL, $sTargetPath, $INET_LOCALCACHE, $INET_DOWNLOADBACKGROUND) ; Show progress UI ProgressOn($sDownloaderTitle, "Downloading " & $sVisibleName) ; Keep checking until download completed Do Sleep(250) ; Set vars Local $iDLPercentage = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) * 100 / $iFileSize, 0) Local $iDLBytes = Round(InetGetInfo($hFileDownload, $INET_DOWNLOADREAD) / $iMBbytes, 2) Local $iDLTotalBytes = Round($iFileSize / $iMBbytes, 2) ; Update progress UI If IsNumber($iDLBytes) And $iDLBytes >= 0 Then ProgressSet($iDLPercentage, $iDLPercentage & "% - Baixado " & $iDLBytes & " MB de " & $iDLTotalBytes & " MB") Else ProgressSet(0, "Baixando '" & $sVisibleName & "'") EndIf Until InetGetInfo($hFileDownload, $INET_DOWNLOADCOMPLETE) ; If the download was successfull, return the target location If InetGetInfo($hFileDownload, $INET_DOWNLOADSUCCESS) Then ProgressSet(100, "Downloading '" & $sVisibleName & "' completed") If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf Return $sTargetPath ; If the download failed, set @error and return False Else Local $errorCode = InetGetInfo($hFileDownload, $INET_DOWNLOADERROR) ProgressSet(0, "Downloading '" & $sVisibleName & "' failed." & @CRLF & "Error code: " & $errorCode) If $bProgressOff Then Sleep($iEndMsgTime) ProgressOff() EndIf SetError(1, $errorCode, False) EndIf EndFunc ;==>_webDownloader $sDownloaderTitle = "Instalação Vetor Soluções" $url = "http://get.enterprisedb.com/postgresql/postgresql-9.5.1-1-windows-x64.exe" $file = "postgresql-9.5.1-1-windows-x64.exe" $name = "PostgreSQL 9.5.1-1 Windows x64" $dir = @TempDir & "\" & $sDownloaderTitle $installcommand = " --unattendedmodeui none --mode unattended --superpassword '1234' --servicepassword '1234' --serverport 5432 --disable-stackbuilder 'yes' --prefix 'C:\postgres' --datadir 'C:\postgres\data' " $postgres = _webDownloader($url, $file, $name, $dir, $sDownloaderTitle) If $postgres Then ProgressSet(100, "Instalando o sistema...", "Instalando atualmente: " & $name) $exitCode = RunWait($postgres & $installcommand) If $exitCode = 0 Then ProgressSet(100, "Instalação completa") If $exitCode <> 0 Then ProgressSet(0, "A instalação falhou" & @CRLF & "Código do erro: " & $exitCode) Sleep(3000) ProgressOff() FileDelete($postgres) Else ProgressOff() EndIf