- Cliente Windows com modo silencioso e auto-start robusto - Backend Node.js + API REST - Frontend Next.js + Dashboard - Scripts PowerShell de configuração e diagnóstico - Documentação completa - Build scripts para Windows e Linux - Solução de auto-start após reinicialização Resolução do problema: Cliente não voltava ativo após reboot Solução: Registro do Windows + Task Scheduler + Modo silencioso
122 lines
3.9 KiB
PowerShell
122 lines
3.9 KiB
PowerShell
# Instalador PowerShell do NoIdle
|
|
# Alternativa simples sem MSI - Pode ser usado no JumpCloud
|
|
# Uso: .\INSTALADOR_POWERSHELL.ps1 [-Uninstall]
|
|
|
|
param(
|
|
[switch]$Uninstall,
|
|
[switch]$Silent
|
|
)
|
|
|
|
$AppName = "NoIdle"
|
|
$InstallDir = "$env:ProgramFiles\$AppName"
|
|
$ExeName = "NoIdle.exe"
|
|
$ExePath = "$InstallDir\$ExeName"
|
|
$RegKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
if ($Uninstall) {
|
|
if (-not $Silent) {
|
|
Write-Host "Desinstalando $AppName..." -ForegroundColor Yellow
|
|
}
|
|
|
|
# Parar processo se estiver rodando
|
|
$process = Get-Process -Name "NoIdle" -ErrorAction SilentlyContinue
|
|
if ($process) {
|
|
Stop-Process -Name "NoIdle" -Force
|
|
if (-not $Silent) {
|
|
Write-Host "Processo NoIdle parado." -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
# Remover do registro
|
|
Remove-ItemProperty -Path $RegKey -Name $AppName -ErrorAction SilentlyContinue
|
|
if (-not $Silent) {
|
|
Write-Host "Removido do registro." -ForegroundColor Green
|
|
}
|
|
|
|
# Remover arquivos
|
|
if (Test-Path $InstallDir) {
|
|
Remove-Item -Path $InstallDir -Recurse -Force
|
|
if (-not $Silent) {
|
|
Write-Host "Arquivos removidos." -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
if (-not $Silent) {
|
|
Write-Host "Desinstalação concluída!" -ForegroundColor Green
|
|
}
|
|
exit 0
|
|
}
|
|
|
|
# INSTALAÇÃO
|
|
if (-not $Silent) {
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Instalando $AppName" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
}
|
|
|
|
# Verificar se já está instalado
|
|
if (Test-Path $ExePath) {
|
|
if (-not $Silent) {
|
|
Write-Host "[AVISO] $AppName já está instalado. Reinstalando..." -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
# Verificar se o executável existe na pasta atual ou no mesmo diretório do script
|
|
$CurrentExe = Join-Path $PSScriptRoot $ExeName
|
|
if (-not (Test-Path $CurrentExe)) {
|
|
# Tentar na pasta atual também
|
|
$CurrentExe = Join-Path (Get-Location) $ExeName
|
|
if (-not (Test-Path $CurrentExe)) {
|
|
Write-Host "[ERRO] $ExeName não encontrado!" -ForegroundColor Red
|
|
Write-Host "Coloque o $ExeName na mesma pasta deste script." -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Criar diretório de instalação
|
|
if (-not $Silent) {
|
|
Write-Host "[1/3] Criando diretório de instalação..." -ForegroundColor Cyan
|
|
}
|
|
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
|
|
|
|
# Copiar executável
|
|
if (-not $Silent) {
|
|
Write-Host "[2/3] Copiando executável..." -ForegroundColor Cyan
|
|
}
|
|
Copy-Item -Path $CurrentExe -Destination $ExePath -Force
|
|
if (-not $Silent) {
|
|
Write-Host "Instalado em: $ExePath" -ForegroundColor Green
|
|
}
|
|
|
|
# Configurar inicialização automática
|
|
if (-not $Silent) {
|
|
Write-Host "[3/3] Configurando inicialização automática..." -ForegroundColor Cyan
|
|
}
|
|
Set-ItemProperty -Path $RegKey -Name $AppName -Value $ExePath -Type String
|
|
if (-not $Silent) {
|
|
Write-Host "Configurado para iniciar automaticamente." -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host "Instalação concluída com sucesso!" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Localização: $ExePath" -ForegroundColor Cyan
|
|
Write-Host "Inicialização automática: Configurada" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "Para desinstalar, execute:" -ForegroundColor Yellow
|
|
Write-Host " .\INSTALADOR_POWERSHELL.ps1 -Uninstall" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# Iniciar o programa
|
|
$iniciar = Read-Host "Deseja iniciar o NoIdle agora? (S/N)"
|
|
if ($iniciar -eq "S" -or $iniciar -eq "s") {
|
|
Start-Process $ExePath
|
|
}
|
|
} else {
|
|
# Modo silencioso - apenas instalar
|
|
Start-Process $ExePath -WindowStyle Hidden
|
|
}
|
|
|