Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9091

How to force closing / freeing the serial ports opened by other programs in cmd or Powershell

$
0
0

Following this post, I can use cmd's mode command to see the available / free ports. I can also use the PowerShell (PS) 's oneliner:

Get-WMIObject Win32_SerialPort | Select-Object DeviceID

to see all the existing ports. The difference indicates the Open / busy ports.

Now I want to interrupt (force close) the ports which are open in any way, including the ones opened outside cmd/PS. Please consider

  1. The port is not necessarily opened inside PS. otherwise I could use $<PortName>.Close() to do this.
  2. It has to be a cmd or PS command, not a GUI solution, such as editing the registry or restating the operating system.
  3. I don't want to delete / destroy the port. I just want to be sure they are free (ready to be opened)
  4. It should be preferably a one-liner. Something I can run in just one line. Using piping is ok.

P.S. I have also posted the question here on Reddit


Viewing all articles
Browse latest Browse all 9091

Trending Articles