We help IT Professionals succeed at work.

Sending alerts to staff on a LAN without using "net send"

Medium Priority
Last Modified: 2013-11-13
Our receptionist would like a system where she can alert a particular member of staff when their client has arrived. We are unlikely to use "net send", as this introduces the likelihood of spam messages.

Here's how I envision the setup:
- a "receiving" application running on the staff workstations with a "sending" application running on the receptionist's workstation;
- text string (preset, maybe?) is sent by the receptionist via the LAN, then it would appear as a pop-up at the user's workstation;
- no additional communication is needed from the user to the receptionist;
- the staff do not necessarily use the same computer each time they work - we're networked via a Windows 2003 server, so users are identified by the receptionist by their username;
- ideally the alerts would be those cute little MSN Messenger-style ones with the text string inserted as the label, but I think I can do that part already.

Is this possible to implement without using "net send"? I have some knowledge of VB, but I haven't done much network-based programming.
Watch Question

Most firewalls blocking incomming "net send" messages nowdays... so I'd think that using "net send" within your LAN would be a reasonable (and safe) approach.   Perhaps you might reconsider?
consider using http://www.pandion.be/. It is like AIM except you control who can log on and keep it business related.

You can make your own but you better of taking a demo chat program written in VB and just customize it your way to save time and the hassle to learn something from scratch.

You can go to www.freevbcode.com and do a search on chat.

Here is one http://freevbcode.com/ShowCode.Asp?ID=7652

There are a number of ways you could do this...

The suggestion(s) above are both valid points.  If however you were looking at doing this completely yourself in VB and don't wish to use any previously created applications then you could consider the following:

Use a 'server' application which sits on the receptionists computer.  This application with listen for incoming connections from the client applications (which will sit on the users PCs).

Once the client has connected to the server it can send it a message telling the server who's currently logged onto the station (you can use some API calls to retrieve their username).  The server can then track who's connected from which machine and allow the receptionist to send them messages.

Commonly the connections and transfer of messages between server/client is done using the Winsock control.

As lunchbyte has suggested you can take a look around sites like www.freevbcode.com and www.planet-source-code.com where you'll find numerous examples of how to do this.

Hope this has helped, cheers


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Shiju SasidharanSenior IT Developer



Okay, I've got a basic setup going on: a client app with a "listener" which waits for a string to be passed from the "server" app.

I've done some searching on P-S-C.com and freevbcode.com etc, but I can't work out how to use the required API calls. The "server" app needs to retrieve its own username (based upon the current user; we have 3 receptionists), then retrieve the usernames of all logged-in users on the LAN.

Presumably it would then be possible to pass a string to a client app sitting on the workstation of a particular user, selected from a list at the "server" app-side.
The way I would do it is to approach it from a slightly different method.

Have a server application which sits either on one of the receptionist's machines or on a server or some sort, then client applications which connect to the server application.

The server app could use an array of winsock controls to accept multiple connections.

When a client connects it should give the server the name of the person on the local machine and the name of the location machine.  The server should then store this some how, either in a collection or in the Tag property of the winsock control from which the client is connecting.

You could then give the receptionist's the option of sending messages out to everyone or to individual users who are logged in simply by looping the winsock controls currently loaded and checking their tag property, or by looping the collection object, whichever method you chose best.

For performance you would need to keep track of unused winsock controls that you have loaded, e.g. remember to unload the winsock when the user disconnects or when you forcefully disconnect them.  Best thing is to look for some example code on accepting multiple connections using winsock, the majority of these cover different methods of tracking the active controls.

Some example methods of getting the username of the person currently logged on and the name of the computer they are using which can then be sent to the server...

' API Calls
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Long

Declare Function GetComputerName Lib "kernel32" Alias
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

' Public Functions
Public Function GetUser() As String
   On Error GoTo errH

   Dim sUser As String
   Dim lpBuff As String * 1024

   GetUserName lpBuff, Len(lpBuff)
   sUser = Left$(lpBuff, (InStr(1, lpBuff, vbNullChar)) - 1)

   GetUser = sUser
   Exit Function

   GetUser = ""
End Function

Public Function GetComputer() As String

  Dim strBuffer As String * 255

  If GetComputerName(strBuffer, 255&) <> 0 Then
     ' Name exist
     ComputerName = Left(strBuffer, InStr(strBuffer, vbNullChar) - 1)
     ' Name doesn't exist
     ComputerName = "N/A"
  End If

End Function

Note: above isn't my code, it's code I've found on Internet somewhere and I email it myself so I can access it anywhere without having to bookmark anything, so unfortauntely I can't give credit to the original author, can only state I didn't create it myself.  From what I've seen it's a pretty standard way of retrieving this information.




Thanks to everyone for their input!

I've now got a program using the code supplied by ShelfieldCollege, utilising the API calls I found in various LAN messenger apps on Planet-Source-Code. With the inclusion of the above code, the same program can be placed on all computers; its functionality changes depending on who is logged in.
Glad you've managed to get your project working, cheers.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.