Meilenstein 3: Windows-Anbindung für itrdp:// und itssh://
- Gemeinsame, strenge Link-Prüfung in itconnect-common.ps1 (Regeln wie im Backend, Regex-Ende mit \z, nur Parameter host/port/user) - launch-rdp.ps1: mstsc /v bzw. temporäre .rdp-Datei bei Benutzername - launch-ssh.ps1: wt.exe ssh, Fallback auf ssh.exe - register-handlers.reg / unregister-handlers.reg (HKCU, Skripte unter Program Files) - test-launcher.ps1 mit gültigen und bösartigen Testlinks - .gitattributes: Windows-Dateien unverändert (CRLF, BOM) - SETUP.md: Installation, Test und Fehlerbilder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e89c4ad59
commit
37a60fc62a
8 files changed
+361
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<#
|
||||
Öffnet eine RDP-Verbindung aus einem itrdp://-Link.
|
||||
Wird über den Protokoll-Handler aufgerufen (siehe register-handlers.reg):
|
||||
powershell.exe -File launch-rdp.ps1 "itrdp://connect?host=...&port=...&user=..."
|
||||
Mit -Pruefen wird nur angezeigt, was gestartet würde (für Tests).
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, Position = 0)][AllowEmptyString()][string]$Url,
|
||||
[switch]$Pruefen
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot 'itconnect-common.ps1')
|
||||
|
||||
function Get-ItcRdpBefehl {
|
||||
param([Parameter(Mandatory = $true)]$Ziel)
|
||||
$adresse = Format-ItcAdresse $Ziel
|
||||
if ($null -eq $Ziel.User) {
|
||||
return [pscustomobject]@{ Programm = 'mstsc.exe'; Argumente = ('/v:' + $adresse); RdpInhalt = $null }
|
||||
}
|
||||
# mstsc kennt keinen Benutzer-Parameter, daher eine temporäre .rdp-Datei
|
||||
$inhalt = "full address:s:$adresse`r`nusername:s:$($Ziel.User)`r`n"
|
||||
return [pscustomobject]@{ Programm = 'mstsc.exe'; Argumente = $null; RdpInhalt = $inhalt }
|
||||
}
|
||||
|
||||
try {
|
||||
$ziel = ConvertFrom-ItcUrl -Url $Url -Schema 'itrdp' -StandardPort 3389
|
||||
$befehl = Get-ItcRdpBefehl $ziel
|
||||
|
||||
if ($Pruefen) { return $befehl }
|
||||
|
||||
if ($null -eq $befehl.RdpInhalt) {
|
||||
Start-Process -FilePath $befehl.Programm -ArgumentList $befehl.Argumente
|
||||
} else {
|
||||
$datei = Join-Path $env:TEMP ('it-connect-' + [guid]::NewGuid().ToString() + '.rdp')
|
||||
Set-Content -LiteralPath $datei -Value $befehl.RdpInhalt -Encoding Unicode
|
||||
Start-Process -FilePath $befehl.Programm -ArgumentList ('"' + $datei + '"')
|
||||
# mstsc liest die Datei beim Start; danach wieder aufräumen
|
||||
Start-Sleep -Seconds 10
|
||||
Remove-Item -LiteralPath $datei -ErrorAction SilentlyContinue
|
||||
}
|
||||
} catch {
|
||||
if ($Pruefen) { throw }
|
||||
Show-ItcFehler ('RDP-Verbindung konnte nicht geöffnet werden: ' + $_.Exception.Message)
|
||||
exit 1
|
||||
}
|
||||
Reference in new issue
Block a user