# Put frpc.exe into script/frp/ (same dir as this script). # Priority: 1) reuse local D:\printServer\frpc\frpc.exe 2) download from GitHub. # ASCII only, avoids ANSI encoding issues with Chinese paths. $ErrorActionPreference = 'Stop' $FrpDir = $PSScriptRoot $Exe = Join-Path $FrpDir 'frpc.exe' if (Test-Path $Exe) { Write-Output "frpc.exe already exists: $Exe" exit 0 } New-Item -ItemType Directory -Force -Path $FrpDir | Out-Null # 1) reuse frpc from local printServer project $LocalFrpc = 'D:\printServer\frpc\frpc.exe' if (Test-Path $LocalFrpc) { Copy-Item -Force $LocalFrpc $Exe Write-Output "frpc.exe copied from $LocalFrpc -> $Exe" exit 0 } # 2) download (fallback) $Version = '0.61.1' $ZipName = "frp_${Version}_windows_amd64.zip" $Url = "https://github.com/fatedier/frp/releases/download/v$Version/$ZipName" $TmpZip = Join-Path $FrpDir $ZipName $ExtractDir = Join-Path $FrpDir "frp_${Version}_windows_amd64" Write-Output "Downloading $Url ..." Invoke-WebRequest -Uri $Url -OutFile $TmpZip -UseBasicParsing Write-Output "Extracting ..." Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($TmpZip, $FrpDir) Move-Item -Force (Join-Path $ExtractDir 'frpc.exe') $Exe Remove-Item -Recurse -Force $ExtractDir Remove-Item -Force $TmpZip Write-Output "frpc.exe installed: $Exe"