# Script de Instalacao e Configuracao GS Conect (GS Connect) # Executar como Administrador no Windows $ErrorActionPreference = "Stop" $ClientName = "GS Connect" $CleanName = "GS-Connect" $DestDir = "$env:ProgramFiles\RustDesk" $ExePath = "$DestDir\$ClientName.exe" $IconPath = "$DestDir\gsconect.ico" # Identifica se esta rodando a partir do pacote descompactado ou online $ScriptDir = $PSScriptRoot if (-not $ScriptDir) { $ScriptDir = (Get-Location).Path } $LocalExe = Join-Path $ScriptDir "$CleanName.exe" $LocalIco = Join-Path $ScriptDir "gsconect.ico" $LocalToml = Join-Path $ScriptDir "Gsconect2.toml" if (Test-Path $LocalExe) { Write-Host "Instalando componente local de $ClientName..." -ForegroundColor Cyan $SetupExe = $LocalExe } else { Write-Host "Baixando o aplicativo $ClientName..." -ForegroundColor Cyan $SetupExe = "$env:TEMP\$ClientName-setup.exe" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 try { Invoke-WebRequest -Uri "https://gsconnect.gsurfnet.com/api/pro/download/GS-Connect.exe" -OutFile $SetupExe -UseBasicParsing } catch { Invoke-WebRequest -Uri "https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe" -OutFile $SetupExe -UseBasicParsing } } Write-Host "Executando instalacao silenciosa..." -ForegroundColor Cyan $proc = Start-Process -FilePath $SetupExe -ArgumentList "--silent-install" -PassThru $null = $proc.WaitForExit(35000) Start-Sleep -Seconds 2 if (!(Test-Path $DestDir)) { New-Item -ItemType Directory -Path $DestDir -Force -ErrorAction SilentlyContinue | Out-Null } # Copia executavel com o nome corporativo oficial if (Test-Path "$DestDir\rustdesk.exe") { Copy-Item -Path "$DestDir\rustdesk.exe" -Destination "$DestDir\$ClientName.exe" -Force -ErrorAction SilentlyContinue } if (Test-Path $SetupExe) { Copy-Item -Path $SetupExe -Destination "$DestDir\$ClientName.exe" -Force -ErrorAction SilentlyContinue } # Copia ou baixa o icone oficial if (Test-Path $LocalIco) { Copy-Item -Path $LocalIco -Destination $IconPath -Force -ErrorAction SilentlyContinue } elseif (!(Test-Path $IconPath)) { try { Invoke-WebRequest -Uri "https://gsconnect.gsurfnet.com/api/pro/download/gsconect.ico" -OutFile $IconPath -UseBasicParsing -ErrorAction SilentlyContinue } catch {} } # Conteudo de configuracao oficial $ConfigContent = @' rendezvous_server = 'gsconnect.gsurfnet.com:21116' relay_server = 'gsconnect.gsurfnet.com' api_server = 'https://gsconnect.gsurfnet.com' key = '6G5voXXb6dZwFx3tlAeJS6iXo43q7nOPKaRdi5YESDQ=' [options] custom-rendezvous-server = 'gsconnect.gsurfnet.com' relay-server = 'gsconnect.gsurfnet.com' api-server = 'https://gsconnect.gsurfnet.com' key = '6G5voXXb6dZwFx3tlAeJS6iXo43q7nOPKaRdi5YESDQ=' allow-remote-config-modification = 'Y' allow-remove-device = 'Y' allow-file-transfer = 'Y' allow-terminal = 'Y' allow-clipboard = 'Y' custom-client-notes = 'Central de Operações GS Connect: (48) 3254-8700 | Suporte Corporativo' verification-method = 'use-permanent-password' password = 'Infra@890' '@ # 1. Perfil do usuario atual $ConfigDir = "$env:APPDATA\RustDesk\config" if (!(Test-Path $ConfigDir)) { New-Item -ItemType Directory -Path $ConfigDir -Force | Out-Null } Set-Content -Path "$ConfigDir\RustDesk2.toml" -Value $ConfigContent -Force Set-Content -Path "$ConfigDir\Gsconect2.toml" -Value $ConfigContent -Force # 2. Perfil do servico LocalService $ServiceConfigDir = "$env:WINDIR\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config" if (!(Test-Path $ServiceConfigDir)) { New-Item -ItemType Directory -Path $ServiceConfigDir -Force -ErrorAction SilentlyContinue | Out-Null } if (Test-Path $ServiceConfigDir) { Set-Content -Path "$ServiceConfigDir\RustDesk2.toml" -Value $ConfigContent -Force -ErrorAction SilentlyContinue Set-Content -Path "$ServiceConfigDir\Gsconect2.toml" -Value $ConfigContent -Force -ErrorAction SilentlyContinue } # 3. Perfis existentes em C:\Users Get-ChildItem -Path "C:\Users" -Directory -ErrorAction SilentlyContinue | ForEach-Object { $uConfig = Join-Path $_.FullName "AppData\Roaming\RustDesk\config" try { if (!(Test-Path $uConfig)) { New-Item -ItemType Directory -Path $uConfig -Force -ErrorAction SilentlyContinue | Out-Null } Set-Content -Path (Join-Path $uConfig "RustDesk2.toml") -Value $ConfigContent -Force -ErrorAction SilentlyContinue Set-Content -Path (Join-Path $uConfig "Gsconect2.toml") -Value $ConfigContent -Force -ErrorAction SilentlyContinue } catch {} } # 4. Reinicia o servico RustDesk para carregar a nova configuracao try { Restart-Service -Name "RustDesk" -Force -ErrorAction SilentlyContinue } catch {} # 5. Remove atalhos antigos com o nome 'RustDesk' Get-ChildItem -Path "C:\Users" -Directory -ErrorAction SilentlyContinue | ForEach-Object { Remove-Item -Path "$($_.FullName)\Desktop\RustDesk.lnk" -Force -ErrorAction SilentlyContinue Remove-Item -Path "$($_.FullName)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\RustDesk.lnk" -Force -ErrorAction SilentlyContinue } Remove-Item -Path "$env:PUBLIC\Desktop\RustDesk.lnk" -Force -ErrorAction SilentlyContinue Remove-Item -Path "$env:ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs\RustDesk.lnk" -Force -ErrorAction SilentlyContinue # 6. Cria o atalho oficial com o nome GS Conect e icone corporativo try { $WshShell = New-Object -ComObject WScript.Shell $TargetExe = if (Test-Path "$DestDir\$ClientName.exe") { "$DestDir\$ClientName.exe" } else { "$DestDir\rustdesk.exe" } foreach ($d in @("$env:PUBLIC\Desktop", "$env:USERPROFILE\Desktop", "$env:ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs")) { if (Test-Path $d) { try { $Shortcut = $WshShell.CreateShortcut("$d\$ClientName.lnk") $Shortcut.TargetPath = $TargetExe $Shortcut.Description = "$ClientName - Central de Acesso Remoto" if (Test-Path $IconPath) { $Shortcut.IconLocation = "$IconPath,0" } $Shortcut.Save() } catch {} } } } catch {} # 7. Atualiza o nome, editor e icone no Painel de Controle (Desinstalar Programas do Windows) $UninstallKeys = @( "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk", "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk" ) foreach ($uKey in $UninstallKeys) { if (Test-Path $uKey) { try { Set-ItemProperty -Path $uKey -Name "DisplayName" -Value "$ClientName" -Force -ErrorAction SilentlyContinue Set-ItemProperty -Path $uKey -Name "Publisher" -Value "GSURF Tecnologia" -Force -ErrorAction SilentlyContinue if (Test-Path $IconPath) { Set-ItemProperty -Path $uKey -Name "DisplayIcon" -Value "$IconPath,0" -Force -ErrorAction SilentlyContinue } } catch {} } } Write-Host "" Write-Host "==============================================================" -ForegroundColor Green Write-Host " $ClientName instalado e configurado com sucesso!" -ForegroundColor Green Write-Host "==============================================================" -ForegroundColor Green