Friday, June 19, 2026

di Win 10, install IPOT HOTS

 di Win 10, masuk PowerShell as Administrator:


# =============================================================================

# install_trading_apps.ps1

# Install otomatis: HOTS Mirae Asset & IPOT Indo Premier

# Jalankan sebagai Administrator di Windows 10

# =============================================================================


#Requires -RunAsAdministrator


Set-StrictMode -Version Latest

$ErrorActionPreference = "Stop"


# ─── Konfigurasi ──────────────────────────────────────────────────────────────

$HOTS_URL    = "https://cdn.miraeasset.co.id/hots/hots_setup.exe"

$IPOT_URL    = "https://indopremier.com/xdir/product/ipotexe/ipot_installer.exe"

$HOTS_FILE   = "$env:TEMP\hots_setup.exe"

$IPOT_FILE   = "$env:TEMP\ipot_installer.exe"

$LOG_FILE    = "$env:TEMP\install_trading_apps.log"


# ─── Fungsi helper ────────────────────────────────────────────────────────────

function Write-Log {

    param([string]$Message, [string]$Level = "INFO")

    $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"

    $line = "[$timestamp] [$Level] $Message"

    Write-Host $line -ForegroundColor $(switch ($Level) {

        "INFO"    { "Cyan" }

        "OK"      { "Green" }

        "WARN"    { "Yellow" }

        "ERROR"   { "Red" }

        default   { "White" }

    })

    Add-Content -Path $LOG_FILE -Value $line

}


function Download-File {

    param([string]$Url, [string]$Destination, [string]$AppName)


    Write-Log "Mengunduh $AppName..."

    Write-Log "URL : $Url"

    Write-Log "Tujuan : $Destination"


    # Aktifkan TLS 1.2

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


    try {

        $webClient = New-Object System.Net.WebClient

        $webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)")


        # Progress download

        $sw = [System.Diagnostics.Stopwatch]::StartNew()

        $webClient.DownloadFile($Url, $Destination)

        $sw.Stop()


        $sizeMB = [math]::Round((Get-Item $Destination).Length / 1MB, 2)

        $elapsed = $sw.Elapsed.ToString("mm\:ss")

        Write-Log "$AppName berhasil diunduh: ${sizeMB} MB dalam ${elapsed} menit" "OK"

    }

    catch {

        Write-Log "Gagal mengunduh $AppName`: $_" "ERROR"

        throw

    }

}


function Install-App {

    param(

        [string]$InstallerPath,

        [string]$AppName,

        [string[]]$Arguments

    )


    Write-Log "Menginstal $AppName..."


    if (-not (Test-Path $InstallerPath)) {

        Write-Log "File installer tidak ditemukan: $InstallerPath" "ERROR"

        throw "Installer tidak ada"

    }


    try {

        $proc = Start-Process `

            -FilePath    $InstallerPath `

            -ArgumentList $Arguments `

            -Wait `

            -PassThru


        if ($proc.ExitCode -eq 0 -or $proc.ExitCode -eq 3010) {

            Write-Log "$AppName berhasil diinstal (ExitCode: $($proc.ExitCode))" "OK"

            if ($proc.ExitCode -eq 3010) {

                Write-Log "$AppName membutuhkan restart untuk menyelesaikan instalasi." "WARN"

            }

        } else {

            Write-Log "$AppName installer selesai dengan ExitCode: $($proc.ExitCode)" "WARN"

        }

    }

    catch {

        Write-Log "Gagal menginstal $AppName`: $_" "ERROR"

        throw

    }

}


function Remove-TempFile {

    param([string]$Path, [string]$AppName)

    if (Test-Path $Path) {

        Remove-Item $Path -Force

        Write-Log "File sementara dihapus: $Path" "INFO"

    }

}


# ─── Header ───────────────────────────────────────────────────────────────────

Clear-Host

Write-Host "============================================================" -ForegroundColor Cyan

Write-Host "   Instalasi Otomatis Aplikasi Trading" -ForegroundColor Cyan

Write-Host "   - HOTS Mirae Asset" -ForegroundColor Cyan

Write-Host "   - IPOT Indo Premier" -ForegroundColor Cyan

Write-Host "============================================================" -ForegroundColor Cyan

Write-Host ""

Write-Log "Log disimpan di: $LOG_FILE"

Write-Host ""


# ─── Cek koneksi internet ─────────────────────────────────────────────────────

Write-Log "Memeriksa koneksi internet..."

try {

    $null = Invoke-WebRequest -Uri "https://www.google.com" -UseBasicParsing -TimeoutSec 10

    Write-Log "Koneksi internet OK" "OK"

} catch {

    Write-Log "Tidak ada koneksi internet. Periksa jaringan dan coba lagi." "ERROR"

    exit 1

}


# =============================================================================

# 1. HOTS MIRAE ASSET

# =============================================================================

Write-Host ""

Write-Host "──────────────────────────────────────────" -ForegroundColor Magenta

Write-Host " [1/2] HOTS Mirae Asset" -ForegroundColor Magenta

Write-Host "──────────────────────────────────────────" -ForegroundColor Magenta


try {

    Download-File -Url $HOTS_URL -Destination $HOTS_FILE -AppName "HOTS Mirae Asset"

    Install-App   -InstallerPath $HOTS_FILE -AppName "HOTS Mirae Asset" `

                  -Arguments @("/S", "/v/qn")

    Remove-TempFile -Path $HOTS_FILE -AppName "HOTS Mirae Asset"

    Write-Log "HOTS Mirae Asset selesai ✓" "OK"

} catch {

    Write-Log "HOTS Mirae Asset GAGAL: $_" "ERROR"

    Write-Log "Lanjut ke instalasi berikutnya..." "WARN"

}


# =============================================================================

# 2. IPOT INDO PREMIER

# =============================================================================

Write-Host ""

Write-Host "──────────────────────────────────────────" -ForegroundColor Magenta

Write-Host " [2/2] IPOT Indo Premier" -ForegroundColor Magenta

Write-Host "──────────────────────────────────────────" -ForegroundColor Magenta


try {

    Download-File -Url $IPOT_URL -Destination $IPOT_FILE -AppName "IPOT Indo Premier"

    Install-App   -InstallerPath $IPOT_FILE -AppName "IPOT Indo Premier" `

                  -Arguments @("/S", "/v/qn")

    Remove-TempFile -Path $IPOT_FILE -AppName "IPOT Indo Premier"

    Write-Log "IPOT Indo Premier selesai ✓" "OK"

} catch {

    Write-Log "IPOT Indo Premier GAGAL: $_" "ERROR"

}


# ─── Selesai ──────────────────────────────────────────────────────────────────

Write-Host ""

Write-Host "============================================================" -ForegroundColor Green

Write-Host "   Proses instalasi selesai!" -ForegroundColor Green

Write-Host "   Log lengkap: $LOG_FILE" -ForegroundColor Green

Write-Host "============================================================" -ForegroundColor Green

Write-Host ""

Write-Log "Script selesai dijalankan." "OK"


SELESAI

No comments:

Post a Comment