vb.net USB Port Name/Description - vb.net

I already acquired the code for Name of the modem. But I don't know how to use WMI because I can't really understand how does it works. For now, the code for it is so complicated.
Can you guys help me regarding to name my port? It's RFID Reader and it's USB Port. Look for the image as reference.
This image will show you that in Left Side < I got my COM 7 port in Modem but In right side > I got many option to pick, because my modem opens many port. I need to know how to name my other port(RFID COM PORT) so that I dont need to guess what is the right port for it.
Try
Dim searcher As New ManagementObjectSearcher( _
"root\cimv2", _
"SELECT * FROM Win32_SerialPort")
For Each queryObj As ManagementObject In searcher.Get()
MsgBox(queryObj("Name"))
enter code here
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
So, I change the code, and I just want the system to message me what is the open port. But, unfortunately, My RFID (Profilic USB-to-Serial Comm Port (COM3) is not being shown.
Edit
This is the output messagebox, well as you can see guys, there's no profilic. Even though it's been plugged, and seen by Device Manager.
But If I change the code to Win32_PnPEntity it will show all peripherals, and etc. and eventually It will show the Image

Related

To find what kind of usb is connected to the port using vb.net

I have a com port and i want to send messages to it. I want to be certain that is port is of the type RS 485. How can i do that. I have searched online and the only way i see is through the win32 dll. is there any other way and if there isnt could you please point me to the win32 method.
I have the following code but it doesnt produce any output...
Dim searcher As New ManagementObjectSearcher("root\cimv2", "SELECT * FROM Win32_SerialPort")
For Each queryObj As ManagementObject In searcher.Get()
Dim obj As String = queryObj("Name")
MessageBox.Show(obj)
Next

Confirm USB Device is Connected To Correct Port

Good evening, I have a small challenge that I'm trying to get around. I have a user environment where all devices are 'built' using identical system images and identical hardware. It's a small point of sale environment. The software on the computers requires devices to be connected to particular USB other wise the devices will not work with the software. This presents a lot of issues as the cables aren't physically labelled.
I'm trying to create a small Visual Basic application which is able to check what device is connected to each USB port on the system. The program seems simple to me, but I've been having difficulty with the code for a few days. Is it possible to return the USB Port ID using the code below. I'm able to retrieve then DeviceID, but I now need to compare this with the USB ID to confirm it's in the correct port, how can I retrieve the USB Port ID/Name?
Dim sc As New ManagementScope("\\DESKTOP-BA9EEM9\root\cimv2")
Dim query As New ObjectQuery("Select * from Win32_USBHub")
Dim searcher As New ManagementObjectSearcher(sc, query)
Dim result As ManagementObjectCollection = searcher.Get()
For Each obj As ManagementObject In result
If obj("Description") IsNot Nothing Then
ListBox1.Items.Add("Description:" & vbTab + obj("Description").ToString())
End If
If obj("DeviceID") IsNot Nothing Then
ListBox1.Items.Add("DeviceID:" & vbTab + obj("DeviceID").ToString())
End If
If obj("PNPDeviceID") IsNot Nothing Then
ListBox1.Items.Add("PNPDeviceID:" & vbTab + obj("PNPDeviceID").ToString())
End If
ListBox1.Items.Add("----------------------------------------")

TelnetExpect Reading Output from Stream in VB.NET

Good Morning,
I have been tasked with writing a program that locates the local port a MAC Address is registered to, and to do that I need to SSH and Telnet into Cisco devices and receive the output of the commands so I can parse it and decide what to do with the information.
So far I have the SSH connection and parsing done no problem thanks to Renci.SshNET. But I am having trouble with the Telnet, I set it up to use Telnetlib.dll and I know it works because I can do "show users" on the switch I'm connecting to and see that one of the vty lines are being occupied by my application. But in the application I'm writing all I get is the application freezing up, none of the buttons work, and I can't see the mouse when I hover over the window, so I'm guessing that the application isn't liking something at run-time.
The code I'm using, in VB.NET is:
Using client As TcpClient = New TcpClient(host, 23)
Dim tel As TelnetStream = New TelnetStream(client.GetStream)
Dim buff(client.ReceiveBufferSize) As Byte
Dim result As String
tel.SetRemoteMode(TelnetOption.Echo, False)
Dim exp As Expector = New Expector(tel)
exp.Expect("username: ")
exp.SendLine(username)
exp.Expect("password: ")
exp.SendLine(password)
exp.Expect(">")
tel.Read(buff, 0, buff.Length)
result = System.Text.Encoding.ASCII.GetString(buff)
MessageBox.Show(result)
End Using
Telnetlib.dll include the definitions for the Expector, SendLine, Expect, and TelnetStream.
I did some debugging and found that it freezes when it goes to execute the result = System.Text.Encoding.ASCII.GetString(buff)
command.
Thanks for any help.

Ensure connection to a POSPrinter connected via COM

I need to make sure that the connection to a POS printer is successful before writing data to the database and then printing a receipt. The POSprinter is normally of type BTP 2002NP but may differ. The common thing is that they are all connected via COM-port and NOT usb, so no drivers installed at all on the client.
Can I send some kind of "ping" on a COM-port and check if a device is connected and turned on? Any help or suggestions are very much appreciated.
Additional information, the application is developed in VB.net and Visual Studio 2008
About all you can do is write out a character string to the com port and wait and see if your printer responds with a reply. However the string you write and the string you expect will depend on the printer itself.
Refer to the BTP 2002NP printers programming manual for examples (the first link in google that I looked at)
From looking at the manual an appropriate string to send to the printer is the "DLE EOT n" command which requests that the printer send back its current status.
As for other printers in the range, check out this list of drivers and manuals
btw, this is what i came up with in the end.
Public Function ComTest() As Byte()
Dim TXT As String
TXT = Chr(&H10S) & Chr(&H4S) & Chr(1) 'DLE EOT 1
If OpenCom() Then 'Connect to com
moRS232.PurgeBuffer(Rs232.PurgeBuffers.TxClear Or Rs232.PurgeBuffers.RXClear)
moRS232.Write(TXT)
moRS232.Read(1)
Return moRS232.InputStream
Else
Return Nothing
End If
End Function
the function returns 1 byte. i can then from the manual translate this byte into what state the printer is currently in. this probably works for all ESC/P printers.

Use VBA to call a cellphone

About a year ago, a manager in another department brainstormed that I could code up some VBA to auto call me in the event one of my automated reports crashes. I laughed at the time, but my skills have improved considerably and I wonder if it's technically possible
(not that I'd actually do it, mind you. I like my early Saturday mornings workplace-free).
This would need:
1. Access to the internet (not a problem)
2. A means of connecting to some service to place the call, preferably free, lest I cost the company $10 a month (Skype?)
3. An automated voice (already exists on the standard Access install package)
What do you think?
Edited 08/24/2009 - Spacing added. No text was changed.
Do the simplest thing that could possibly work. In this case, making phonecalls is hard, but sending emails is easy.
Most cellphone providers expose a phone's mailbox (something like 555-867-5309#cellphoneprovider.com) to the internet, allowing you to send an email to that address and have it show up on your phone as a text message.
You can use Skype in combination with VBA. It's actually not that complicated and you will find a couple of samples written in VBScript on the Skype website. I don't know whether it is possible to actually play an audio file, but you can send SMS easily:
'// Create a Skype4COM object:
Set oSkype = WScript.CreateObject("Skype4COM.Skype", "Skype_")
'// Start the Skype client:
If Not oSkype.Client.IsRunning Then oSkype.Client.Start() End If
'// Send SMS:
Set oSMS = oSkype.SendSms("+1234567890", "Hello!")
WScript.Sleep(60000)
'// Message event handler:
Public Sub Skype_SmsMessageStatusChanged(ByRef aSms, ByVal aStatus)
WScript.Echo ">Sms " & aSms.Id & " status " & aStatus & " " & oSkype.Convert.SmsMessageStatusToText(aStatus)
End Sub
'// Target event handler:
Public Sub Skype_SmsTargetStatusChanged(ByRef aTarget, ByVal aStatus)
WScript.Echo ">Sms " & aTarget.Message.Id & " target " & aTarget.Number & " status " & aStatus & " " & oSkype.Convert.SmsTargetStatusToText(aStatus)
End Sub
If you have a old dial up modem, then you could (in 'old VB6 days) dial via the modem programmatically, however I'm not sure if its possible in VBA. The next challange would be to get the audio down the line.
I would suggest that you butcher a headless earphone & microphone that connects to phones, you could then take a 3.5mm audio jack from your PC speaker output and connect this to the headless earphone/microphone set, unless there are cables that already do that (possibly).
Then it would be a simple matter of coding up Microsofts 'text to speech' engine.
Darknight
http://chandoo.org/wp/2009/02/05/twitter-from-excel/. Set up a twitter account that pings your phone and create twitters with this.
It's not as easy as the email idea, but you could be the first person to tweet from Excel for a reason other than novelty.
Another quite simple option is to send yourself a text message which is almost but not quite as easy to do as sending an email, but much easier to recieve. Companies such as clickatell.com provide cheap web based text services with good api's where once you are signed up all you need do is call a URL and you can send a text message.
Well worth a try.