From 4a13bd7d0ddc04d3927f05a9728f4eb5af2a53f1 Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Sun, 28 Apr 2024 20:20:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=85=E7=90=86=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/freePort.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 script/freePort.ps1 diff --git a/script/freePort.ps1 b/script/freePort.ps1 new file mode 100644 index 00000000..c29704aa --- /dev/null +++ b/script/freePort.ps1 @@ -0,0 +1,13 @@ +$defaultPort = 7456 + +$userPort = Read-Host "enter port [$defaultPort]:" + +if ($userPort -eq "") +{ + $userPort = $defaultPort +} + +Write-Host "free port: $userPort" + + +Get-NetTCPConnection -State Listen | Where-Object { $_.LocalPort -eq $userPort } | ForEach-Object { Get-Process -ID $_.OwningProcess } | Stop-Process \ No newline at end of file