Fix SpawnHelper: rename pipeName param to portStr, fix taskName

pipeName[^8..] crashed for 5-char port strings (e.g. "54321").
Now uses port number directly as task name suffix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 10:05:12 +02:00
parent 0b76ef3bfd
commit d3bc68d6a5

View File

@@ -160,7 +160,7 @@ public class RtcService
AgentWorker.Log("RDP: Frame-Loop beendet"); AgentWorker.Log("RDP: Frame-Loop beendet");
} }
private static bool SpawnCaptureHelper(string exePath, string pipeName) private static bool SpawnCaptureHelper(string exePath, string portStr)
{ {
try try
{ {
@@ -171,7 +171,7 @@ public class RtcService
return false; return false;
} }
var taskName = $"ITNexus-RDP-{pipeName[^8..]}"; var taskName = $"ITNexus-RDP-{portStr}";
Process.Start(new ProcessStartInfo("schtasks.exe", $"/delete /tn \"{taskName}\" /f") Process.Start(new ProcessStartInfo("schtasks.exe", $"/delete /tn \"{taskName}\" /f")
{ CreateNoWindow = true })?.WaitForExit(); { CreateNoWindow = true })?.WaitForExit();
@@ -181,7 +181,7 @@ public class RtcService
? "/ru \"INTERACTIVE\"" ? "/ru \"INTERACTIVE\""
: $"/ru \"{fullUser}\""; : $"/ru \"{fullUser}\"";
var args = $"/create /tn \"{taskName}\" /tr \"\\\"{exePath}\\\" --rdp-capture {pipeName}\" " + var args = $"/create /tn \"{taskName}\" /tr \"\\\"{exePath}\\\" --rdp-capture {portStr}\" " +
$"/sc ONCE /st {triggerTime} {ruArg} /it /f"; $"/sc ONCE /st {triggerTime} {ruArg} /it /f";
var p = Process.Start(new ProcessStartInfo("schtasks.exe", args) var p = Process.Start(new ProcessStartInfo("schtasks.exe", args)