Results 1 to 6 of 6

Thread: send a message to another user-rather simple

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    canada
    Posts
    22

    send a message to another user-rather simple

    I want to be able to send a message to another computer on the network the way that you can with using the NET.EXE at the command line as in the format:

    net send "<user>" "<message>"


    I have the both the username and message in variables. Can someone help me with this?


    Thanks,

    Ryan Small

  2. #2
    Matthew Gates
    Guest
    Try both of these ways:


    Code:
    Shell "net send " & user & Chr$(32) & message
    Or:

    Code:
    Shell "command.com /c net send " & user & Chr$(32) & message

  3. #3
    Addicted Member matbrophy's Avatar
    Join Date
    Sep 1999
    Location
    Kent, United Kingdom
    Posts
    149
    is there away of executing dos commands without the dos window appearing?
    Microsoft Visual Basic 6.0 Professional
    Windows XP Professional

  4. #4
    Matthew Gates
    Guest
    You can hide the window.


    Code:
    Shell "net send " & user & Chr$(32) & message, 0 'or vbHide

  5. #5
    Hyperactive Member SjR's Avatar
    Join Date
    Jul 2001
    Location
    Birmingham, UK
    Posts
    336
    Does any one no if its possible to send a message to a computer that has the messenger service disabled (temporarily enable and then disable afterwards?) BTW, Logon scripts is not an option.
    Thanks

  6. #6
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    To send a network message using visual basic code, use the netMessageBufferSend api.

    In a .bas module:
    Code:
    Private Declare Function NetMessageBufferSend Lib "netapi32" (ByVal ServerName As String, ByVal msgname As String, ByVal fromname As String, ByVal msgbuf As String, ByRef msgbuflen As Long) As Long
    Private Const ERROR_ACCESS_DENIED As Long = 5
    Private Const ERROR_BAD_NETPATH As Long = 53
    Private Const ERROR_INVALID_PARAMETER As Long = 87
    Private Const ERROR_NOT_SUPPORTED As Long = 50
    Private Const ERROR_INVALID_NAME As Long = 123
    Private Const NERR_BASE As Long = 2100
    Private Const NERR_Success As Long = 0                'success
    Private Const NERR_NetworkError As Long = (NERR_BASE + 36)   'general network error occurred.
    Private Const NERR_NameNotFound As Long = (NERR_BASE + 173)  'message alias could not be found on the network.
    Private Const NERR_UseNotFound As Long = (NERR_BASE + 150)   'network connection could not be found.
    
    
    Public Function NetSendMessage(ByVal sMessage As String, ByVal sTo As String, ByRef errMessage As String, Optional sFrom As String, Optional Server As String) As Boolean
    Dim retVal As Long
        If Len(Trim(sTo)) > 0 Then
            sTo = StrConv(sTo, vbUnicode)
            If Len(sMessage) = 0 Then
                sMessage = vbNullString
            Else
                sMessage = StrConv(sMessage, vbUnicode)
            End If
            If Len(sFrom) = 0 Then
                sFrom = vbNullString
            Else
                sFrom = StrConv(sFrom, vbUnicode)
            End If
            If Len(Server) = 0 Then
                Server = vbNullString
            Else
                Server = StrConv(Server, vbUnicode)
            End If
            retVal = NetMessageBufferSend(Server, sTo, sFrom, sMessage, ByVal Len(sMessage))
            NetSendMessage = retVal = 0
            Select Case retVal
                Case ERROR_ACCESS_DENIED
                    errMessage = "Access denied"
                Case ERROR_BAD_NETPATH
                    errMessage = "Bad network path"
                Case ERROR_INVALID_PARAMETER
                    errMessage = "Invalid parameter"
                Case ERROR_NOT_SUPPORTED
                    errMessage = "not supported"
                Case ERROR_INVALID_NAME
                    errMessage = "Invalid name"
                Case NERR_NetworkError
                    errMessage = "General network error"
                Case NERR_NameNotFound
                    errMessage = "Message alias could not be found on the network."
                Case NERR_UseNotFound
                    errMessage = "Network connection could not be found."
                Case NERR_Success
                    errMessage = "Operation succeeded"
                Case Else
                    errMessage = "Unknown error"
            End Select
        Else
            NetSendMessage = False
            errMessage = "No recipient selected"
        End If
    End Function
    To receive the message, the recipient needs to run a messenger service. A messenger service is basically not more then a program that periodically checks the messenger mailslot "\\.\mailslot\messngr" for files, and displays the contents of the file in a messagebox.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width