Force assign COM ports using command line.

Joined
Jan 23, 2017
Messages
5
Reaction score
0
Hi, please move if this is in the wrong place.

I need to force Windows 10 to accept two USB devices on specific COM Ports and have come up blank on how to do this via Command Line.

I can clear all 'hidden' devices to ensure the required COM Ports are free using the following code -

Code:
@ECHO OFF
FOR %%i IN (C D E F G H I J K) DO IF EXIST %%i:\remove.cmd SET Drive=%%i:
%DRIVE%\DEVCON Find * | FIND /I /V "matching device(s)" > "%DRIVE%\DevicesExist.txt"

FOR /F "tokens=1 delims=: " %%A IN ('%DRIVE%\DEVCON FindAll * ^| FIND /I /V "%DRIVE%\matching device(s)"') DO (
        TYPE "%DRIVE%\DevicesExist.txt" | FIND "%%~A" >NUL
       IF ERRORLEVEL 1 %Debug% %DRIVE%\DEVCON Remove "@%%~A"
)
Del "%DRIVE%\DevicesExist.txt"

But when I plug in the two Devices I need to assign them to COM Port 4 & 5 respectfully .. does anyone have any idea how to go about this .. I understand it will require adjusting registry entries.

TIA for any help
 

Regedit32

Moderator
Joined
Mar 4, 2016
Messages
3,617
Reaction score
1,139
Can you not more simply:
  • Open Device Manager
  • Expand Ports (COM & LPT)
  • Right-click on the device you want to change com port on, and select Properties
  • Select the Port Settings tab
  • Click the Advanced button
  • Select the Com you want and click OK
Note: the device needs to plugged in and turned on to be detected in Device Manager in order to change com ports.​
 

Regedit32

Moderator
Joined
Mar 4, 2016
Messages
3,617
Reaction score
1,139
Well you could take a look at the DEVCON information page produced by Microsoft:

https://msdn.microsoft.com/en-us/windows/hardware/drivers/devtest/devcon-restart

There may be some useful information there.

In earlier editions of Windows there was the change portX = portY command, but the problem with that is it only assigns the port while User is logged on, thus you'd have to do this each time you wished to used your device.

To be honest I'm not even sure whether that very old MS-Dos is even supported now.

So it seems you will need to download support packages as you apparently already have done re the DEVCON
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top