I am creating a batch file to remove virtual com ports created before using com0com. at the time of creation, the port names where renamed for example:
change CNCA2 portname=COM20
So when i want to remove i should use the original name like:
remove 2
which corresponds to the original portname CNCA2
So, what i m trying to do here is if the user chooses to remove Port COM20, how can get the
original name which is CNCxx
?
below is the sample of command i used:
as u can see, when i write remove COM150
there is no change, so i need to get the corresponding name which is remove 2
.
so from the c# application how can i get the corresponding name without manually using a list
command?
Thanks.
You could spawn a command prompt process that runs the list command and capture the output by redirecting stdout to a text file. Then read the results back from the file.
From the example above, it should be relatively simple to parse the results and use them to create a Dictionary, so you can then easily look up the original name given the new name.