Reset atualizacao 2026

This commit is contained in:
2026-02-12 11:10:45 -03:00
commit 1099a5c301
17 changed files with 2218 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

108
habilita-vlt-pilot.ps1 Normal file
View File

@@ -0,0 +1,108 @@
# Elevate privileges if needed
if (-not ([Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator))) {
Start-Process powershell -Verb runAs -ArgumentList $MyInvocation.MyCommand.Definition
exit
}
function Show-Banner {
Clear-Host
Write-Host @"
PILOT - VLT
"@ -ForegroundColor Cyan
}
function Show-Menu {
Show-Banner
Write-Host "========== CONFIGURATION MENU ==========" -ForegroundColor Cyan
Write-Host "1. Enable High Performance Power Plan"
Write-Host "2. Rename PC using MAC Address"
Write-Host "3. Run both (1 and 2)"
Write-Host "4. Install Notepad++, .NET 8, VC++"
Write-Host "5. Disable UAC and Notifications"
Write-Host "6. Exit"
Write-Host "========================================`n"
}
function Set-HighPerformancePowerPlan() {
Write-Output "`nActivating High Performance power plan..."
$highPerf = powercfg -l | Where-Object { $_ -match "High performance" -or $_ -match "Alto desempenho" }
if ($highPerf) {
$guid = ($highPerf -split '\s+')[3]
powercfg -setactive $guid
powercfg -change -monitor-timeout-ac 0
powercfg -change -monitor-timeout-dc 0
powercfg -change -standby-timeout-ac 0
powercfg -change -standby-timeout-dc 0
powercfg -change -disk-timeout-ac 0
powercfg -change -disk-timeout-dc 0
Write-Output "Power settings applied successfully.`n"
} else {
Write-Output "High Performance power plan not found.`n"
}
}
function Rename-PCToMac() {
Write-Output "`nRenaming PC using MAC address..."
$mac = (Get-NetAdapter -InterfaceAlias "*Ethernet*" | Select-Object -First 1 -ExpandProperty MacAddress) -replace '-', ''
if ($mac) {
Rename-Computer -NewName "$mac" -Force
Write-Output "Computer renamed to: $mac"
Write-Output "Please restart the computer to apply the change.`n"
} else {
Write-Output "Could not retrieve MAC address.`n"
}
}
function Install-CommonTools() {
Write-Output "`nInstalling tools and dependencies via winget..."
try {
winget install -e --id Notepad++.Notepad++ --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.DotNet.DesktopRuntime.8 --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.VCRedist.2015+.x64 --accept-source-agreements --accept-package-agreements
Write-Output "Installation completed.`n"
} catch {
Write-Output "Installation error: $_"
}
}
function Disable-UACAndNotifications() {
Write-Output "`nDisabling UAC and notifications..."
try {
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Force | Out-Null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Name "DisableEnhancedNotifications" -Type DWord -Value 1
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchBoxTaskbarMode -Value 0 -Type DWord -Force
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Write-Output "UAC and notifications disabled.`n"
} catch {
Write-Output "Error while configuring system: $_"
}
}
# Main loop
do {
Show-Menu
$choice = Read-Host "Select an option (1-6)"
switch ($choice) {
"1" { Set-HighPerformancePowerPlan }
"2" { Rename-PCToMac }
"3" {
Set-HighPerformancePowerPlan
Rename-PCToMac
}
"4" { Install-CommonTools }
"5" { Disable-UACAndNotifications }
"6" { Write-Host "`nExiting..." -ForegroundColor Yellow }
default { Write-Host "`nInvalid option. Please try again." -ForegroundColor Red }
}
if ($choice -ne "6") {
Pause
}
} while ($choice -ne "6")

View File

@@ -0,0 +1,210 @@
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
# Verify Admin Rights
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole]::Administrator)) {
[System.Windows.Forms.MessageBox]::Show("Restarting as Administrator...")
Start-Process powershell "-ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
function Write-Log {
param ($text)
$outputBox.AppendText("$text`r`n")
$outputBox.ScrollToCaret()
}
function Stop-Unity {
Write-Log "Stopping unity.exe and cabinet.exe if running..."
try {
Stop-Process -Name "unity" -Force -ErrorAction Stop
Write-Log "unity.exe process stopped."
} catch {
Write-Log "unity.exe was not running or could not be stopped."
}
try {
Stop-Process -Name "cabinet" -Force -ErrorAction Stop
Write-Log "cabinet.exe process stopped."
} catch {
Write-Log "cabinet.exe was not running or could not be stopped."
}
}
function Update-StartBat {
param ([string]$Mode)
$batPath = "C:\\pilotgames\\start.bat"
if ($Mode -eq "Portrait") {
$content = @"
cd /D C:\pilotgames\NDGDRelease
powershell -command "Start-Process cabinet.exe -Verb runas -ArgumentList '-screen-height', '1920', '-screen-width','1080', '-screen-fullscreen', '0', '-popupwindow'"
"@
} else {
$content = @"
cd /D C:\pilotgames\BRGDRelease
powershell -command "Start-Process cabinet.exe -Verb runas -ArgumentList '-screen-height', '1080', '-screen-width','1920', '-screen-fullscreen', '0', '-popupwindow'"
"@
}
Write-Log "Updating start.bat for $Mode..."
Set-Content -Path $batPath -Value $content -Force -Encoding ASCII
Write-Log "start.bat updated."
}
function Install-Pilot {
param ([string]$Mode)
$outputBox.Clear()
Write-Log "Starting $Mode installation..."
if ($Mode -eq "Portrait") {
$zipFile = "NDGDRelease-2025.07.15.1.zip"
$orient = "Portrait"
} else {
$zipFile = "NDGDRelease-2025.06.17.1.zip"
$orient = "Dual"
}
Write-Log "Stopping PilotGameAgent service..."
Stop-Service -Name "PilotGameAgent" -Force -ErrorAction SilentlyContinue
Stop-Unity
pushd "C:\\pilotgames"
Write-Log "Clearing downloads folder..."
Remove-Item -Path "C:\\pilotgames\\downloads\\*" -Force -Recurse -ErrorAction SilentlyContinue
Write-Log "Removing backup folders..."
Remove-Item -Path "C:\\pilotgames\\BRGDRelease.bak" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\\pilotgames\\NDGDRelease.bak" -Recurse -Force -ErrorAction SilentlyContinue
Write-Log "Waiting 10 seconds..."
Start-Sleep -Seconds 10
if (Test-Path "C:\\pilotgames\\BRGDRelease") {
Write-Log "Backing up BRGDRelease folder..."
Move-Item "C:\\pilotgames\\BRGDRelease" "C:\\pilotgames\\BRGDRelease.bak" -Force
}
if (Test-Path "C:\\pilotgames\\NDGDRelease") {
Write-Log "Backing up NDGDRelease folder..."
Move-Item "C:\\pilotgames\\NDGDRelease" "C:\\pilotgames\\NDGDRelease.bak" -Force
}
Write-Log "Copying release zip file..."
$zipPath = "C:\\pilotDownloads\\$orient\\$zipFile"
Copy-Item -Path $zipPath -Destination "C:\\pilotgames\\downloads\\" -Force
Write-Log "Unzipping file into C:\\pilotgames..."
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, "C:\\pilotgames")
Update-StartBat -Mode $Mode
Write-Log "Waiting 20 seconds..."
Start-Sleep -Seconds 20
Write-Log "Starting PilotGameAgent service..."
Set-Service -Name "PilotGameAgent" -StartupType Automatic -PassThru
Start-Service -Name "PilotGameAgent"
Write-Log "$Mode installation completed successfully."
}
function Set-HighPerformancePowerPlan {
Write-Log "`nActivating High Performance power plan..."
$highPerf = powercfg -l | Where-Object { $_ -match "High performance" -or $_ -match "Alto desempenho" }
if ($highPerf) {
$guid = ($highPerf -split '\s+')[3]
powercfg -setactive $guid
powercfg -change -monitor-timeout-ac 0
powercfg -change -monitor-timeout-dc 0
powercfg -change -standby-timeout-ac 0
powercfg -change -standby-timeout-dc 0
powercfg -change -disk-timeout-ac 0
powercfg -change -disk-timeout-dc 0
Write-Log "Power settings applied successfully.`n"
} else {
Write-Log "High Performance power plan not found.`n"
}
}
function Rename-PCToMac {
Write-Log "`nRenaming PC using MAC address..."
$mac = (Get-NetAdapter -InterfaceAlias "*Ethernet*" | Select-Object -First 1 -ExpandProperty MacAddress) -replace '-', ''
if ($mac) {
Rename-Computer -NewName "$mac" -Force
Write-Log "Computer renamed to: $mac"
Write-Log "Please restart the computer to apply the change.`n"
} else {
Write-Log "Could not retrieve MAC address.`n"
}
}
function Install-CommonTools {
Write-Log "`nInstalling tools and dependencies via winget..."
try {
winget install -e --id Notepad++.Notepad++ --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.DotNet.DesktopRuntime.8 --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.VCRedist.2015+.x64 --accept-source-agreements --accept-package-agreements
Write-Log "Installation completed.`n"
} catch {
Write-Log "Installation error: $_"
}
}
function Disable-UACAndNotifications {
Write-Log "`nDisabling UAC and notifications..."
try {
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Force | Out-Null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Name "DisableEnhancedNotifications" -Type DWord -Value 1
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchBoxTaskbarMode -Value 0 -Type DWord -Force
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Write-Log "UAC and notifications disabled.`n"
} catch {
Write-Log "Error while configuring system: $_"
}
}
# GUI
$form = New-Object System.Windows.Forms.Form
$form.Text = "Pilot Installer"
$form.Size = New-Object System.Drawing.Size(600,500)
$form.StartPosition = "CenterScreen"
$buttons = @(
@{ Text = "Install Portrait"; Action = { Install-Pilot -Mode "Portrait" } },
@{ Text = "Install Dual"; Action = { Install-Pilot -Mode "Dual" } },
@{ Text = "Exit"; Action = { $form.Close() } }
)
$x = 10
foreach ($btn in $buttons) {
$button = New-Object System.Windows.Forms.Button
$button.Text = $btn.Text
$button.Size = New-Object System.Drawing.Size(140,30)
$button.Location = New-Object System.Drawing.Point($x,20)
$button.Add_Click($btn.Action)
$form.Controls.Add($button)
$x += 150
}
$outputBox = New-Object System.Windows.Forms.TextBox
$outputBox.Multiline = $true
$outputBox.ScrollBars = "Vertical"
$outputBox.ReadOnly = $true
$outputBox.Size = New-Object System.Drawing.Size(560,370)
$outputBox.Location = New-Object System.Drawing.Point(10,70)
$outputBox.Font = New-Object System.Drawing.Font("Consolas",10)
$outputBox.Name = "OutputTextBox"
$form.Controls.Add($outputBox)
$form.Topmost = $true
$form.ShowDialog()

View File

@@ -0,0 +1,220 @@
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
# Verify Admin Rights
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole]::Administrator)) {
[System.Windows.Forms.MessageBox]::Show("Restarting as Administrator...")
Start-Process powershell "-ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
function Write-Log {
param ($text)
$outputBox.AppendText("$text`r`n")
$outputBox.ScrollToCaret()
}
function Stop-Unity {
Write-Log "Stopping unity.exe and cabinet.exe if running..."
try {
Stop-Process -Name "unity" -Force -ErrorAction Stop
Write-Log "unity.exe process stopped."
} catch {
Write-Log "unity.exe was not running or could not be stopped."
}
try {
Stop-Process -Name "cabinet" -Force -ErrorAction Stop
Write-Log "cabinet.exe process stopped."
} catch {
Write-Log "cabinet.exe was not running or could not be stopped."
}
}
function Update-StartBat {
param ([string]$Mode)
$batPath = "C:\\pilotgames\\start.bat"
if ($Mode -eq "Portrait") {
$content = @"
cd /D C:\pilotgames\NDGDRelease
powershell -command "Start-Process cabinet.exe -Verb runas -ArgumentList '-screen-height', '1920', '-screen-width','1080', '-screen-fullscreen', '0', '-popupwindow'"
"@
} else {
$content = @"
cd /D C:\pilotgames\BRGDRelease
powershell -command "Start-Process cabinet.exe -Verb runas -ArgumentList '-screen-height', '1080', '-screen-width','1920', '-screen-fullscreen', '0', '-popupwindow'"
"@
}
Write-Log "Updating start.bat for $Mode..."
Set-Content -Path $batPath -Value $content -Force -Encoding ASCII
Write-Log "start.bat updated."
}
function Install-Pilot {
param ([string]$Mode)
$outputBox.Clear()
Write-Log "Starting $Mode installation..."
if ($Mode -eq "Portrait") {
$zipFile = "NDGDRelease-2025.08.07.1.zip"
$orient = "Portrait"
} else {
$zipFile = "NDGDRelease-2025.06.17.1.zip"
$orient = "Dual"
}
Write-Log "`nRenaming PC using MAC address..."
$mac = (Get-NetAdapter -InterfaceAlias "*Ethernet*" | Select-Object -First 1 -ExpandProperty MacAddress) -replace '-', ''
if ($mac) {
Rename-Computer -NewName "$mac" -Force
Write-Log "Computer renamed to: $mac"
Write-Log "Please restart the computer to apply the change.`n"
} else {
Write-Log "Could not retrieve MAC address.`n"
}
Write-Log "Stopping PilotGameAgent service..."
Stop-Service -Name "PilotGameAgent" -Force -ErrorAction SilentlyContinue
Stop-Unity
pushd "C:\\pilotgames"
Write-Log "Clearing downloads folder..."
Remove-Item -Path "C:\\pilotgames\\downloads\\*" -Force -Recurse -ErrorAction SilentlyContinue
Write-Log "Removing backup folders..."
Remove-Item -Path "C:\\pilotgames\\BRGDRelease.bak" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\\pilotgames\\NDGDRelease.bak" -Recurse -Force -ErrorAction SilentlyContinue
Write-Log "Waiting 10 seconds..."
Start-Sleep -Seconds 10
if (Test-Path "C:\\pilotgames\\BRGDRelease") {
Write-Log "Backing up BRGDRelease folder..."
Move-Item "C:\\pilotgames\\BRGDRelease" "C:\\pilotgames\\BRGDRelease.bak" -Force
}
if (Test-Path "C:\\pilotgames\\NDGDRelease") {
Write-Log "Backing up NDGDRelease folder..."
Move-Item "C:\\pilotgames\\NDGDRelease" "C:\\pilotgames\\NDGDRelease.bak" -Force
}
Write-Log "Copying release zip file..."
$zipPath = "C:\\pilotDownloads\\$orient\\$zipFile"
Copy-Item -Path $zipPath -Destination "C:\\pilotgames\\downloads\\" -Force
Write-Log "Unzipping file into C:\\pilotgames..."
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, "C:\\pilotgames")
Update-StartBat -Mode $Mode
Write-Log "Waiting 20 seconds..."
Start-Sleep -Seconds 20
Write-Log "Starting PilotGameAgent service..."
Set-Service -Name "PilotGameAgent" -StartupType Automatic -PassThru
Start-Service -Name "PilotGameAgent"
Write-Log "$Mode installation completed successfully."
}
function Set-HighPerformancePowerPlan {
Write-Log "`nActivating High Performance power plan..."
$highPerf = powercfg -l | Where-Object { $_ -match "High performance" -or $_ -match "Alto desempenho" }
if ($highPerf) {
$guid = ($highPerf -split '\s+')[3]
powercfg -setactive $guid
powercfg -change -monitor-timeout-ac 0
powercfg -change -monitor-timeout-dc 0
powercfg -change -standby-timeout-ac 0
powercfg -change -standby-timeout-dc 0
powercfg -change -disk-timeout-ac 0
powercfg -change -disk-timeout-dc 0
Write-Log "Power settings applied successfully.`n"
} else {
Write-Log "High Performance power plan not found.`n"
}
}
function Rename-PCToMac {
Write-Log "`nRenaming PC using MAC address..."
$mac = (Get-NetAdapter -InterfaceAlias "*Ethernet*" | Select-Object -First 1 -ExpandProperty MacAddress) -replace '-', ''
if ($mac) {
Rename-Computer -NewName "$mac" -Force
Write-Log "Computer renamed to: $mac"
Write-Log "Please restart the computer to apply the change.`n"
} else {
Write-Log "Could not retrieve MAC address.`n"
}
}
function Install-CommonTools {
Write-Log "`nInstalling tools and dependencies via winget..."
try {
winget install -e --id Notepad++.Notepad++ --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.DotNet.DesktopRuntime.8 --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.VCRedist.2015+.x64 --accept-source-agreements --accept-package-agreements
Write-Log "Installation completed.`n"
} catch {
Write-Log "Installation error: $_"
}
}
function Disable-UACAndNotifications {
Write-Log "`nDisabling UAC and notifications..."
try {
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Force | Out-Null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Name "DisableEnhancedNotifications" -Type DWord -Value 1
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchBoxTaskbarMode -Value 0 -Type DWord -Force
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Write-Log "UAC and notifications disabled.`n"
} catch {
Write-Log "Error while configuring system: $_"
}
}
# GUI
$form = New-Object System.Windows.Forms.Form
$form.Text = "Pilot Installer"
$form.Size = New-Object System.Drawing.Size(600,500)
$form.StartPosition = "CenterScreen"
$buttons = @(
@{ Text = "Install Portrait"; Action = { Install-Pilot -Mode "Portrait" } },
@{ Text = "Install Dual"; Action = { Install-Pilot -Mode "Dual" } },
@{ Text = "Exit"; Action = { $form.Close() } }
)
$x = 10
foreach ($btn in $buttons) {
$button = New-Object System.Windows.Forms.Button
$button.Text = $btn.Text
$button.Size = New-Object System.Drawing.Size(140,30)
$button.Location = New-Object System.Drawing.Point($x,20)
$button.Add_Click($btn.Action)
$form.Controls.Add($button)
$x += 150
}
$outputBox = New-Object System.Windows.Forms.TextBox
$outputBox.Multiline = $true
$outputBox.ScrollBars = "Vertical"
$outputBox.ReadOnly = $true
$outputBox.Size = New-Object System.Drawing.Size(560,370)
$outputBox.Location = New-Object System.Drawing.Point(10,70)
$outputBox.Font = New-Object System.Drawing.Font("Consolas",10)
$outputBox.Name = "OutputTextBox"
$form.Controls.Add($outputBox)
$form.Topmost = $true
$form.ShowDialog()

View File

@@ -0,0 +1,154 @@
<#
Atualiza C:\plhDownloads\ com o conteúdo do repositório (branch main)
http://git.mgcs.com.br/suporte/vlt-install e executa pl_inst.ps1
Requisitos:
- PowerShell com permissões para escrever em C:\plhDownloads\
- Preferível executar em janela elevada (winget pode pedir UAC)
O script:
1) Garante winget e usa-o para instalar/atualizar Git (Git.Git).
2) Clona/atualiza o repo em pasta temporária.
3) Copia por cima (sem /MIR) para C:\plhDownloads\ (exclui .git).
4) Executa pl_inst.ps1
#>
$ErrorActionPreference = 'Stop'
# ===== Configurações =====
$RepoUrl = 'http://git.mgcs.com.br/suporte/vlt-install'
$Branch = 'main' # sempre main
$TargetDir = 'C:\plhDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
# ===== Utilitárias =====
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget {
return [bool](Get-Command winget -ErrorAction SilentlyContinue)
}
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store para habilitar o winget."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements')
# Detecta se Git está instalado
$gitInstalled = $false
try {
# 'winget list' retorna errolevel 0 mesmo sem pacote; interpretamos saída
$list = winget list --id Git.Git -e 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
# silencia prompts; se não houver upgrade disponível, winget finaliza OK.
winget upgrade --id Git.Git -e @argsCommon --silent | Out-Null
} else {
Write-Info "Instalando Git..."
winget install --id Git.Git -e @argsCommon --silent | Out-Null
}
# Garante que o git esteja acessível
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if (-not $gitCmd) {
# tenta caminho usual
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) {
$env:Path = "C:\Program Files\Git\cmd;$env:Path"
}
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
# ===== Fluxo principal =====
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
# Prepara/atualiza repositório no diretório de trabalho
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório existente em $WorkDir ..."
Push-Location $WorkDir
try { git remote set-url origin $RepoUrl | Out-Null } catch { }
git fetch --all --prune
git checkout $Branch
git reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
git clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
# Copiar por cima para o destino (sem espelhar/sem apagar o que já existe)
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$log = Join-Path $env:TEMP 'vlt-install_copy.log'
# Robocopy:
# /E -> inclui subpastas (inclui vazias)
# /IS -> inclui arquivos “iguais” (força overwrite)
# /IT -> inclui arquivos “tweak”
# /XO -> (opcional) pula arquivos mais antigos na origem; REMOVIDO para forçar overwrite
# /NFL /NDL /NP -> logs mais limpos
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$log
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $log"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $log"
}
# Executa o instalador
$InstallScript = Join-Path $TargetDir 'pl_inst.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pl_inst.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pl_inst.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
}

View File

@@ -0,0 +1,154 @@
<#
Atualiza C:\plhDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1.ps1
Requisitos:
- PowerShell com permissões para escrever em C:\plhDownloads\
- Preferível executar em janela elevada (winget pode pedir UAC)
O script:
1) Garante winget e usa-o para instalar/atualizar Git (Git.Git).
2) Clona/atualiza o repo em pasta temporária.
3) Copia por cima (sem /MIR) para C:\plhDownloads\ (exclui .git).
4) Executa pilot_install.ps1.ps1
#>
$ErrorActionPreference = 'Stop'
# ===== Configurações =====
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install'
$Branch = 'main' # sempre main
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
# ===== Utilitárias =====
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget {
return [bool](Get-Command winget -ErrorAction SilentlyContinue)
}
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store para habilitar o winget."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements')
# Detecta se Git está instalado
$gitInstalled = $false
try {
# 'winget list' retorna errolevel 0 mesmo sem pacote; interpretamos saída
$list = winget list --id Git.Git -e 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
# silencia prompts; se não houver upgrade disponível, winget finaliza OK.
winget upgrade --id Git.Git -e @argsCommon --silent | Out-Null
} else {
Write-Info "Instalando Git..."
winget install --id Git.Git -e @argsCommon --silent | Out-Null
}
# Garante que o git esteja acessível
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if (-not $gitCmd) {
# tenta caminho usual
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) {
$env:Path = "C:\Program Files\Git\cmd;$env:Path"
}
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
# ===== Fluxo principal =====
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
# Prepara/atualiza repositório no diretório de trabalho
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório existente em $WorkDir ..."
Push-Location $WorkDir
try { git remote set-url origin $RepoUrl | Out-Null } catch { }
git fetch --all --prune
git checkout $Branch
git reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
git clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
# Copiar por cima para o destino (sem espelhar/sem apagar o que já existe)
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$log = Join-Path $env:TEMP 'vlt-install_copy.log'
# Robocopy:
# /E -> inclui subpastas (inclui vazias)
# /IS -> inclui arquivos “iguais” (força overwrite)
# /IT -> inclui arquivos “tweak”
# /XO -> (opcional) pula arquivos mais antigos na origem; REMOVIDO para forçar overwrite
# /NFL /NDL /NP -> logs mais limpos
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$log
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $log"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $log"
}
# Executa o instalador
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
}

View File

@@ -0,0 +1,154 @@
<#
Atualiza C:\plhDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1
Requisitos:
- PowerShell com permissões para escrever em C:\plhDownloads\
- Preferível executar em janela elevada (winget pode pedir UAC)
O script:
1) Garante winget e usa-o para instalar/atualizar Git (Git.Git).
2) Clona/atualiza o repo em pasta temporária.
3) Copia por cima (sem /MIR) para C:\plhDownloads\ (exclui .git).
4) Executa pilot_install.ps1
#>
$ErrorActionPreference = 'Stop'
# ===== Configurações =====
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install'
$Branch = 'main' # sempre main
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
# ===== Utilitárias =====
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget {
return [bool](Get-Command winget -ErrorAction SilentlyContinue)
}
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store para habilitar o winget."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements')
# Detecta se Git está instalado
$gitInstalled = $false
try {
# 'winget list' retorna errolevel 0 mesmo sem pacote; interpretamos saída
$list = winget list --id Git.Git -e 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
# silencia prompts; se não houver upgrade disponível, winget finaliza OK.
winget upgrade --id Git.Git -e @argsCommon --silent | Out-Null
} else {
Write-Info "Instalando Git..."
winget install --id Git.Git -e @argsCommon --silent | Out-Null
}
# Garante que o git esteja acessível
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if (-not $gitCmd) {
# tenta caminho usual
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) {
$env:Path = "C:\Program Files\Git\cmd;$env:Path"
}
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
# ===== Fluxo principal =====
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
# Prepara/atualiza repositório no diretório de trabalho
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório existente em $WorkDir ..."
Push-Location $WorkDir
try { git remote set-url origin $RepoUrl | Out-Null } catch { }
git fetch --all --prune
git checkout $Branch
git reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
git clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
# Copiar por cima para o destino (sem espelhar/sem apagar o que já existe)
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$log = Join-Path $env:TEMP 'vlt-install_copy.log'
# Robocopy:
# /E -> inclui subpastas (inclui vazias)
# /IS -> inclui arquivos “iguais” (força overwrite)
# /IT -> inclui arquivos “tweak”
# /XO -> (opcional) pula arquivos mais antigos na origem; REMOVIDO para forçar overwrite
# /NFL /NDL /NP -> logs mais limpos
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$log
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $log"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $log"
}
# Executa o instalador
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
}

View File

@@ -0,0 +1,151 @@
<#
Atualiza C:\plhDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1
Requisitos:
- PowerShell com permissões para escrever em C:\plhDownloads\
- Preferível executar em janela elevada (winget pode pedir UAC)
O script:
1) Garante winget e usa-o para instalar/atualizar Git (Git.Git).
2) Clona/atualiza o repo em pasta temporária.
3) Copia por cima (sem /MIR) para C:\plhDownloads\ (exclui .git).
4) Executa pilot_install.ps1
#>
$ErrorActionPreference = 'Stop'
# ===== Configurações =====
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install'
$Branch = 'main' # sempre main
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
# ===== Utilitárias =====
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget {
return [bool](Get-Command winget -ErrorAction SilentlyContinue)
}
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store para habilitar o winget."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements','--silent')
# Detecta se Git está instalado
$gitInstalled = $false
try {
$list = winget list --id Git.Git -e 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
& winget upgrade --id Git.Git -e @argsCommon | Out-Null
} else {
Write-Info "Instalando Git..."
& winget install --id Git.Git -e @argsCommon | Out-Null
}
# Garante que o git esteja acessível
$gitCmd = Get-Command git -ErrorAction SilentlyContinue
if (-not $gitCmd) {
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) {
$env:Path = "C:\Program Files\Git\cmd;$env:Path"
}
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
# ===== Fluxo principal =====
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
# Prepara/atualiza repositório no diretório de trabalho
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório existente em $WorkDir ..."
Push-Location $WorkDir
try { git remote set-url origin $RepoUrl | Out-Null } catch { }
git fetch --all --prune
git checkout $Branch
git reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
git clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
# Copiar por cima para o destino (sem espelhar/sem apagar o que já existe)
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$log = Join-Path $env:TEMP 'vlt-install_copy.log'
# Robocopy:
# /E -> inclui subpastas (inclui vazias)
# /IS -> inclui arquivos “iguais” (força overwrite)
# /IT -> inclui arquivos “tweak”
# /XO -> (opcional) pula arquivos mais antigos na origem; REMOVIDO para forçar overwrite
# /NFL /NDL /NP -> logs mais limpos
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$log
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $log"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $log"
}
# Executa o instalador
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
}

View File

@@ -0,0 +1,195 @@
<#
Atualiza C:\PilotDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1
Recursos:
- Instala/atualiza Git via winget
- Evita abrir navegador (sem prompts do GCM)
- Suporte a token do Gitea (param ou arquivo)
- Copia por cima (não espelha)
#>
param(
[string]$GitUser, # opcional: usuário do Gitea
[string]$GitToken, # opcional: PAT do Gitea
[string]$GitTokenPath # opcional: caminho de arquivo contendo somente o token
)
$ErrorActionPreference = 'Stop'
# ===== Configurações =====
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install' # sem credenciais na URL
$Branch = 'main'
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
$CopyLog = Join-Path $env:TEMP 'vlt-install_copy.log'
# ===== Utilitárias =====
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget { [bool](Get-Command winget -ErrorAction SilentlyContinue) }
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' pela Microsoft Store para habilitar o winget."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements','--silent')
# Detecta se Git está instalado
$gitInstalled = $false
try {
$list = winget list --id Git.Git -e @argsCommon 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
& winget upgrade --id Git.Git -e @argsCommon | Out-Null
} else {
Write-Info "Instalando Git..."
& winget install --id Git.Git -e @argsCommon | Out-Null
}
# Garante PATH do git
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) { $env:Path = "C:\Program Files\Git\cmd;$env:Path" }
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
function Get-GitTokenEffective {
if ($GitToken) { return $GitToken }
if ($GitTokenPath) {
if (-not (Test-Path -LiteralPath $GitTokenPath)) {
throw "Arquivo de token não encontrado: $GitTokenPath"
}
return (Get-Content -LiteralPath $GitTokenPath -Raw).Trim()
}
return $null
}
function Get-BasicAuthHeader([string]$user,[string]$token){
if (-not $user -or -not $token) { return $null }
$bytes = [Text.Encoding]::ASCII.GetBytes("$user`:$token")
$base64 = [Convert]::ToBase64String($bytes)
return "Authorization: Basic $base64"
}
function Get-GitCommonArgs {
param([string]$AuthHeader)
# Evita prompts/UI/navegador e askpass
$args = @(
'-c','credential.helper=',
'-c','credential.interactive=never',
'-c','core.askPass='
)
# Se fornecer header, usa-o nesta chamada (não grava no .git/config)
if ($AuthHeader) {
$args += @('-c',"http.extraHeader=$AuthHeader")
}
return ,$args
}
# ===== Início =====
try {
# Auto-desbloqueia este arquivo (elimina marca de internet se houver)
try { Unblock-File -LiteralPath $MyInvocation.MyCommand.Path -ErrorAction SilentlyContinue } catch { }
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
# Prepara credenciais (opcionais)
$EffectiveToken = Get-GitTokenEffective
if ($GitUser -and -not $EffectiveToken) {
Write-Warn "GitUser informado mas nenhum token fornecido. Continuação sem autenticação."
}
$AuthHeader = $null
if ($GitUser -and $EffectiveToken) {
$AuthHeader = Get-BasicAuthHeader -user $GitUser -token $EffectiveToken
Write-Info "Usando autenticação via header (sem gravar credenciais em .git/config)."
}
# Nunca abrir prompts/navegador
$env:GIT_TERMINAL_PROMPT = '0'
# Clone/Update
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório em $WorkDir ..."
Push-Location $WorkDir
try { & git (Get-GitCommonArgs -AuthHeader $AuthHeader) remote set-url origin $RepoUrl | Out-Null } catch { }
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) fetch --all --prune
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) checkout $Branch
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
# Copiar por cima (sem espelhar)
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$CopyLog
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $CopyLog"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $CopyLog"
}
# Executa o instalador
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
} finally {
# Limpa variáveis sensíveis do ambiente
Remove-Item Env:\GIT_TERMINAL_PROMPT -ErrorAction SilentlyContinue
}

View File

@@ -0,0 +1,157 @@
<#
Atualiza C:\PilotDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1
Ajuste as variáveis $GitUser e $GitToken conforme necessário.
#>
# ========= CONFIGURAÇÃO DE USUÁRIO/TOKEN =========
$GitUser = "seu.usuario" # coloque aqui seu usuário do Gitea
$GitToken = "seu_token_pat" # coloque aqui o Personal Access Token do Gitea
# ================================================
$ErrorActionPreference = 'Stop'
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install'
$Branch = 'main'
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
$CopyLog = Join-Path $env:TEMP 'vlt-install_copy.log'
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget { [bool](Get-Command winget -ErrorAction SilentlyContinue) }
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements','--silent')
$gitInstalled = $false
try {
$list = winget list --id Git.Git -e 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
& winget upgrade --id Git.Git -e @argsCommon | Out-Null
} else {
Write-Info "Instalando Git..."
& winget install --id Git.Git -e @argsCommon | Out-Null
}
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) { $env:Path = "C:\Program Files\Git\cmd;$env:Path" }
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
function Get-BasicAuthHeader([string]$user,[string]$token){
if (-not $user -or -not $token) { return $null }
$bytes = [Text.Encoding]::ASCII.GetBytes("$user`:$token")
$base64 = [Convert]::ToBase64String($bytes)
return "Authorization: Basic $base64"
}
function Get-GitCommonArgs {
param([string]$AuthHeader)
$args = @(
'-c','credential.helper=',
'-c','credential.interactive=never',
'-c','core.askPass='
)
if ($AuthHeader) {
$args += @('-c',"http.extraHeader=$AuthHeader")
}
return ,$args
}
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
$AuthHeader = $null
if ($GitUser -and $GitToken) {
$AuthHeader = Get-BasicAuthHeader -user $GitUser -token $GitToken
Write-Info "Usando autenticação com header."
}
$env:GIT_TERMINAL_PROMPT = '0'
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório em $WorkDir ..."
Push-Location $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) fetch --all --prune
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) checkout $Branch
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$CopyLog
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $CopyLog"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $CopyLog"
}
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
} finally {
Remove-Item Env:\GIT_TERMINAL_PROMPT -ErrorAction SilentlyContinue
}

View File

@@ -0,0 +1,157 @@
<#
Atualiza C:\PilotDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1
Ajuste as variáveis $GitUser e $GitToken conforme necessário.
#>
# ========= CONFIGURAÇÃO DE USUÁRIO/TOKEN =========
$GitUser = "ricardo.sarda" # coloque aqui seu usuário do Gitea
$GitToken = "d6504f7d969c77a51dcbd5854a1f37f0a96398cd" # coloque aqui o Personal Access Token do Gitea
# ================================================
$ErrorActionPreference = 'Stop'
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install'
$Branch = 'main'
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
$CopyLog = Join-Path $env:TEMP 'vlt-install_copy.log'
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget { [bool](Get-Command winget -ErrorAction SilentlyContinue) }
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements','--silent')
$gitInstalled = $false
try {
$list = winget list --id Git.Git -e 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
& winget upgrade --id Git.Git -e @argsCommon | Out-Null
} else {
Write-Info "Instalando Git..."
& winget install --id Git.Git -e @argsCommon | Out-Null
}
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) { $env:Path = "C:\Program Files\Git\cmd;$env:Path" }
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
function Get-BasicAuthHeader([string]$user,[string]$token){
if (-not $user -or -not $token) { return $null }
$bytes = [Text.Encoding]::ASCII.GetBytes("$user`:$token")
$base64 = [Convert]::ToBase64String($bytes)
return "Authorization: Basic $base64"
}
function Get-GitCommonArgs {
param([string]$AuthHeader)
$args = @(
'-c','credential.helper=',
'-c','credential.interactive=never',
'-c','core.askPass='
)
if ($AuthHeader) {
$args += @('-c',"http.extraHeader=$AuthHeader")
}
return ,$args
}
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
$AuthHeader = $null
if ($GitUser -and $GitToken) {
$AuthHeader = Get-BasicAuthHeader -user $GitUser -token $GitToken
Write-Info "Usando autenticação com header."
}
$env:GIT_TERMINAL_PROMPT = '0'
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório em $WorkDir ..."
Push-Location $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) fetch --all --prune
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) checkout $Branch
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$CopyLog
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $CopyLog"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $CopyLog"
}
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
} finally {
Remove-Item Env:\GIT_TERMINAL_PROMPT -ErrorAction SilentlyContinue
}

View File

@@ -0,0 +1,169 @@
<#
Atualiza C:\PilotDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1
Ajuste as variáveis $GitUser e $GitToken conforme necessário.
#>
# ========= CONFIGURAÇÃO DE USUÁRIO/TOKEN =========
$GitUser = "ricardo.sarda" # coloque aqui seu usuário do Gitea
$GitToken = "d6504f7d969c77a51dcbd5854a1f37f0a96398cd" # coloque aqui o Personal Access Token do Gitea
# ================================================
$ErrorActionPreference = 'Stop'
# ===== Auto-desbloqueio (MOTW) =====
try {
$scriptPath = $MyInvocation.MyCommand.Path
if ($scriptPath -and (Test-Path -LiteralPath $scriptPath)) {
Unblock-File -LiteralPath $scriptPath -ErrorAction SilentlyContinue
# remove explicitamente o ADS se existir (não falha se não existir)
Remove-Item -LiteralPath "$scriptPath`:Zone.Identifier" -Force -ErrorAction SilentlyContinue
}
} catch {}
# ===== Configurações =====
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install'
$Branch = 'main'
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
$CopyLog = Join-Path $env:TEMP 'vlt-install_copy.log'
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget { [bool](Get-Command winget -ErrorAction SilentlyContinue) }
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements','--silent')
$gitInstalled = $false
try {
$list = winget list --id Git.Git -e 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
& winget upgrade --id Git.Git -e @argsCommon | Out-Null
} else {
Write-Info "Instalando Git..."
& winget install --id Git.Git -e @argsCommon | Out-Null
}
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) { $env:Path = "C:\Program Files\Git\cmd;$env:Path" }
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
function Get-BasicAuthHeader([string]$user,[string]$token){
if (-not $user -or -not $token) { return $null }
$bytes = [Text.Encoding]::ASCII.GetBytes("$user`:$token")
$base64 = [Convert]::ToBase64String($bytes)
return "Authorization: Basic $base64"
}
function Get-GitCommonArgs {
param([string]$AuthHeader)
$args = @(
'-c','credential.helper=',
'-c','credential.interactive=never',
'-c','core.askPass='
)
if ($AuthHeader) {
$args += @('-c',"http.extraHeader=$AuthHeader")
}
return ,$args
}
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
$AuthHeader = $null
if ($GitUser -and $GitToken) {
$AuthHeader = Get-BasicAuthHeader -user $GitUser -token $GitToken
Write-Info "Usando autenticação com header."
}
$env:GIT_TERMINAL_PROMPT = '0'
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório em $WorkDir ..."
Push-Location $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) fetch --all --prune
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) checkout $Branch
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$CopyLog
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $CopyLog"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $CopyLog"
}
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
exit 0
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
} finally {
Remove-Item Env:\GIT_TERMINAL_PROMPT -ErrorAction SilentlyContinue
}

220
pilot_install.ps1 Normal file
View File

@@ -0,0 +1,220 @@
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
# Verify Admin Rights
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole]::Administrator)) {
[System.Windows.Forms.MessageBox]::Show("Restarting as Administrator...")
Start-Process powershell "-ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
function Write-Log {
param ($text)
$outputBox.AppendText("$text`r`n")
$outputBox.ScrollToCaret()
}
function Stop-Unity {
Write-Log "Stopping unity.exe and cabinet.exe if running..."
try {
Stop-Process -Name "unity" -Force -ErrorAction Stop
Write-Log "unity.exe process stopped."
} catch {
Write-Log "unity.exe was not running or could not be stopped."
}
try {
Stop-Process -Name "cabinet" -Force -ErrorAction Stop
Write-Log "cabinet.exe process stopped."
} catch {
Write-Log "cabinet.exe was not running or could not be stopped."
}
}
function Update-StartBat {
param ([string]$Mode)
$batPath = "C:\\pilotgames\\start.bat"
if ($Mode -eq "Portrait") {
$content = @"
cd /D C:\pilotgames\NDGDRelease
powershell -command "Start-Process cabinet.exe -Verb runas -ArgumentList '-screen-height', '1920', '-screen-width','1080', '-screen-fullscreen', '0', '-popupwindow'"
"@
} else {
$content = @"
cd /D C:\pilotgames\BRGDRelease
powershell -command "Start-Process cabinet.exe -Verb runas -ArgumentList '-screen-height', '1080', '-screen-width','1920', '-screen-fullscreen', '0', '-popupwindow'"
"@
}
Write-Log "Updating start.bat for $Mode..."
Set-Content -Path $batPath -Value $content -Force -Encoding ASCII
Write-Log "start.bat updated."
}
function Install-Pilot {
param ([string]$Mode)
$outputBox.Clear()
Write-Log "Starting $Mode installation..."
if ($Mode -eq "Portrait") {
$zipFile = "NDGDRelease-2026.02.11.3.zip"
$orient = "Portrait"
} else {
$zipFile = "NDGDRelease-2026.02.06.4.zip"
$orient = "Dual"
}
Write-Log "`nRenaming PC using MAC address..."
$mac = (Get-NetAdapter -InterfaceAlias "*Ethernet*" | Select-Object -First 1 -ExpandProperty MacAddress) -replace '-', ''
if ($mac) {
Rename-Computer -NewName "$mac" -Force
Write-Log "Computer renamed to: $mac"
Write-Log "Please restart the computer to apply the change.`n"
} else {
Write-Log "Could not retrieve MAC address.`n"
}
Write-Log "Stopping PilotGameAgent service..."
Stop-Service -Name "PilotGameAgent" -Force -ErrorAction SilentlyContinue
Stop-Unity
pushd "C:\\pilotgames"
Write-Log "Clearing downloads folder..."
Remove-Item -Path "C:\\pilotgames\\downloads\\*" -Force -Recurse -ErrorAction SilentlyContinue
Write-Log "Removing backup folders..."
Remove-Item -Path "C:\\pilotgames\\BRGDRelease.bak" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\\pilotgames\\NDGDRelease.bak" -Recurse -Force -ErrorAction SilentlyContinue
Write-Log "Waiting 10 seconds...."
Start-Sleep -Seconds 10
if (Test-Path "C:\\pilotgames\\BRGDRelease") {
Write-Log "Backing up BRGDRelease folder..."
Move-Item "C:\\pilotgames\\BRGDRelease" "C:\\pilotgames\\BRGDRelease.bak" -Force
}
if (Test-Path "C:\\pilotgames\\NDGDRelease") {
Write-Log "Backing up NDGDRelease folder..."
Move-Item "C:\\pilotgames\\NDGDRelease" "C:\\pilotgames\\NDGDRelease.bak" -Force
}
Write-Log "Copying release zip file..."
$zipPath = "C:\\pilotDownloads\\$orient\\$zipFile"
Copy-Item -Path $zipPath -Destination "C:\\pilotgames\\downloads\\" -Force
Write-Log "Unzipping file into C:\\pilotgames..."
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, "C:\\pilotgames")
Update-StartBat -Mode $Mode
Write-Log "Waiting 20 seconds..."
Start-Sleep -Seconds 20
Write-Log "Starting PilotGameAgent service..."
Set-Service -Name "PilotGameAgent" -StartupType Automatic -PassThru
Start-Service -Name "PilotGameAgent"
Write-Log "$Mode installation completed successfully."
}
function Set-HighPerformancePowerPlan {
Write-Log "`nActivating High Performance power plan..."
$highPerf = powercfg -l | Where-Object { $_ -match "High performance" -or $_ -match "Alto desempenho" }
if ($highPerf) {
$guid = ($highPerf -split '\s+')[3]
powercfg -setactive $guid
powercfg -change -monitor-timeout-ac 0
powercfg -change -monitor-timeout-dc 0
powercfg -change -standby-timeout-ac 0
powercfg -change -standby-timeout-dc 0
powercfg -change -disk-timeout-ac 0
powercfg -change -disk-timeout-dc 0
Write-Log "Power settings applied successfully.`n"
} else {
Write-Log "High Performance power plan not found.`n"
}
}
function Rename-PCToMac {
Write-Log "`nRenaming PC using MAC address..."
$mac = (Get-NetAdapter -InterfaceAlias "*Ethernet*" | Select-Object -First 1 -ExpandProperty MacAddress) -replace '-', ''
if ($mac) {
Rename-Computer -NewName "$mac" -Force
Write-Log "Computer renamed to: $mac"
Write-Log "Please restart the computer to apply the change.`n"
} else {
Write-Log "Could not retrieve MAC address.`n"
}
}
function Install-CommonTools {
Write-Log "`nInstalling tools and dependencies via winget..."
try {
winget install -e --id Notepad++.Notepad++ --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.DotNet.DesktopRuntime.8 --accept-source-agreements --accept-package-agreements
winget install -e --id Microsoft.VCRedist.2015+.x64 --accept-source-agreements --accept-package-agreements
Write-Log "Installation completed.`n"
} catch {
Write-Log "Installation error: $_"
}
}
function Disable-UACAndNotifications {
Write-Log "`nDisabling UAC and notifications..."
try {
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA -Value 0
Set-ItemProperty -Path REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Force | Out-Null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications" -Name "DisableEnhancedNotifications" -Type DWord -Value 1
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchBoxTaskbarMode -Value 0 -Type DWord -Force
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
Write-Log "UAC and notifications disabled.`n"
} catch {
Write-Log "Error while configuring system: $_"
}
}
# GUI
$form = New-Object System.Windows.Forms.Form
$form.Text = "Pilot Installer"
$form.Size = New-Object System.Drawing.Size(600,500)
$form.StartPosition = "CenterScreen"
$buttons = @(
@{ Text = "Install Portrait"; Action = { Install-Pilot -Mode "Portrait" } },
@{ Text = "Install Dual"; Action = { Install-Pilot -Mode "Dual" } },
@{ Text = "Exit"; Action = { $form.Close() } }
)
$x = 10
foreach ($btn in $buttons) {
$button = New-Object System.Windows.Forms.Button
$button.Text = $btn.Text
$button.Size = New-Object System.Drawing.Size(140,30)
$button.Location = New-Object System.Drawing.Point($x,20)
$button.Add_Click($btn.Action)
$form.Controls.Add($button)
$x += 150
}
$outputBox = New-Object System.Windows.Forms.TextBox
$outputBox.Multiline = $true
$outputBox.ScrollBars = "Vertical"
$outputBox.ReadOnly = $true
$outputBox.Size = New-Object System.Drawing.Size(560,370)
$outputBox.Location = New-Object System.Drawing.Point(10,70)
$outputBox.Font = New-Object System.Drawing.Font("Consolas",10)
$outputBox.Name = "OutputTextBox"
$form.Controls.Add($outputBox)
$form.Topmost = $true
$form.ShowDialog()

View File

@@ -0,0 +1,169 @@
<#
Atualiza C:\PilotDownloads\ com o conteúdo do repositório (branch main)
https://gitea.magicis.com.br/PilotSupport/vlt-install e executa pilot_install.ps1
Ajuste as variáveis $GitUser e $GitToken conforme necessário.
#>
# ========= CONFIGURAÇÃO DE USUÁRIO/TOKEN =========
$GitUser = "ricardo.sarda" # coloque aqui seu usuário do Gitea
$GitToken = "d6504f7d969c77a51dcbd5854a1f37f0a96398cd" # coloque aqui o Personal Access Token do Gitea
# ================================================
$ErrorActionPreference = 'Stop'
# ===== Auto-desbloqueio (MOTW) =====
try {
$scriptPath = $MyInvocation.MyCommand.Path
if ($scriptPath -and (Test-Path -LiteralPath $scriptPath)) {
Unblock-File -LiteralPath $scriptPath -ErrorAction SilentlyContinue
# remove explicitamente o ADS se existir (não falha se não existir)
Remove-Item -LiteralPath "$scriptPath`:Zone.Identifier" -Force -ErrorAction SilentlyContinue
}
} catch {}
# ===== Configurações =====
$RepoUrl = 'https://gitea.magicis.com.br/PilotSupport/vlt-install'
$Branch = 'main'
$TargetDir = 'C:\PilotDownloads'
$WorkDir = Join-Path $env:TEMP 'vlt-install_repo'
$CopyLog = Join-Path $env:TEMP 'vlt-install_copy.log'
function Write-Info($m){ Write-Host "[INFO ] $m" -ForegroundColor Cyan }
function Write-Ok($m) { Write-Host "[ OK ] $m" -ForegroundColor Green }
function Write-Warn($m){ Write-Host "[WARN ] $m" -ForegroundColor Yellow }
function Write-Err($m) { Write-Host "[ERRO ] $m" -ForegroundColor Red }
function Ensure-Dir([string]$Path){
if (-not (Test-Path -LiteralPath $Path)) {
New-Item -ItemType Directory -Path $Path -Force | Out-Null
}
}
function Test-Winget { [bool](Get-Command winget -ErrorAction SilentlyContinue) }
function Ensure-Git-WithWinget {
if (-not (Test-Winget)) {
Write-Err "winget não encontrado. Instale o 'App Installer' da Microsoft Store."
throw "winget ausente"
}
Write-Info "Verificando Git via winget..."
$argsCommon = @('--accept-package-agreements','--accept-source-agreements','--silent')
$gitInstalled = $false
try {
$list = winget list --id Git.Git -e @argsCommon 2>$null
if ($list -match 'Git\s+Git') { $gitInstalled = $true }
} catch { }
if ($gitInstalled) {
Write-Info "Atualizando Git (se necessário)..."
& winget upgrade --id Git.Git -e @argsCommon | Out-Null
} else {
Write-Info "Instalando Git..."
& winget install --id Git.Git -e @argsCommon | Out-Null
}
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
$maybeGit = 'C:\Program Files\Git\cmd\git.exe'
if (Test-Path $maybeGit) { $env:Path = "C:\Program Files\Git\cmd;$env:Path" }
}
$ver = git --version 2>$null
if (-not $ver) { throw "Git não acessível após instalação/atualização." }
Write-Ok "Git pronto: $ver"
}
function Get-BasicAuthHeader([string]$user,[string]$token){
if (-not $user -or -not $token) { return $null }
$bytes = [Text.Encoding]::ASCII.GetBytes("$user`:$token")
$base64 = [Convert]::ToBase64String($bytes)
return "Authorization: Basic $base64"
}
function Get-GitCommonArgs {
param([string]$AuthHeader)
$args = @(
'-c','credential.helper=',
'-c','credential.interactive=never',
'-c','core.askPass='
)
if ($AuthHeader) {
$args += @('-c',"http.extraHeader=$AuthHeader")
}
return ,$args
}
try {
Ensure-Git-WithWinget
Ensure-Dir $TargetDir
$AuthHeader = $null
if ($GitUser -and $GitToken) {
$AuthHeader = Get-BasicAuthHeader -user $GitUser -token $GitToken
Write-Info "Usando autenticação com header."
}
$env:GIT_TERMINAL_PROMPT = '0'
if (Test-Path (Join-Path $WorkDir '.git')) {
Write-Info "Atualizando repositório em $WorkDir ..."
Push-Location $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) fetch --all --prune
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) checkout $Branch
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) reset --hard "origin/$Branch"
Pop-Location
} else {
Write-Info "Clonando repositório (branch $Branch) para $WorkDir ..."
try { Remove-Item -LiteralPath $WorkDir -Recurse -Force -ErrorAction SilentlyContinue } catch { }
Ensure-Dir $WorkDir
& git (Get-GitCommonArgs -AuthHeader $AuthHeader) clone --depth 1 --branch $Branch $RepoUrl $WorkDir
Write-Ok "Clone concluído."
}
Write-Info "Copiando arquivos para $TargetDir (sem espelhar)..."
$rc = robocopy `
$WorkDir `
$TargetDir `
* `
/E /IS /IT /R:1 /W:1 /NFL /NDL /NP `
/XD ".git" `
/XF ".gitignore" ".gitattributes" `
/LOG:$CopyLog
if ($LASTEXITCODE -ge 8) {
Write-Err "Falha ao copiar arquivos. Veja o log: $CopyLog"
exit $LASTEXITCODE
} else {
Write-Ok "Cópia finalizada. (código robocopy: $LASTEXITCODE) Log: $CopyLog"
}
$InstallScript = Join-Path $TargetDir 'pilot_install.ps1'
if (Test-Path -LiteralPath $InstallScript) {
Write-Info "Executando $InstallScript ..."
try { Unblock-File -LiteralPath $InstallScript -ErrorAction SilentlyContinue } catch { }
$p = Start-Process -FilePath 'powershell.exe' -ArgumentList @(
'-NoProfile','-ExecutionPolicy','Bypass','-File', $InstallScript
) -Wait -PassThru
if ($p.ExitCode -ne 0) {
Write-Err "pilot_install.ps1 retornou código $($p.ExitCode)."
exit $p.ExitCode
} else {
Write-Ok "pilot_install.ps1 executado com sucesso."
}
} else {
Write-Warn "Arquivo não encontrado: $InstallScript. Execução ignorada."
}
Write-Ok "Processo concluído."
Stop-Process -Id $PID -Force
} catch {
Write-Err ("Erro: " + $_.Exception.Message)
exit 1
} finally {
Remove-Item Env:\GIT_TERMINAL_PROMPT -ErrorAction SilentlyContinue
}

BIN
pilotsupport.exe Normal file

Binary file not shown.