Results 1 to 3 of 3

Thread: net send on winnt

  1. #1

    Thread Starter
    Lively Member Armatendo's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    68

    net send on winnt

    wasup all, i was wondering if there is a way to send messages via a textbox on winnt, i know that i can put a shell command behind a button

    shell "net send 212-1 helo",1

    where 212-1 is the comp number and helo is the message

    this is the command that i have behind my button, i have been messing about and tryint o get it so that i can type into a text box and click send so that the text in the text box will send.

    this is what i have got, but it doesn't work:-

    shell "net send 212-1" + (text1.text),1

    can somebody tell me where i am going wrong.

  2. #2
    Member
    Join Date
    Nov 2000
    Posts
    48
    "cmd /c net send 212-1 helo"


  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Lets do it VB way
    Module code
    VB Code:
    1. Option Explicit
    2. Private Type OSVERSIONINFO
    3.         dwOSVersionInfoSize As Long
    4.         dwMajorVersion As Long
    5.         dwMinorVersion As Long
    6.         dwBuildNumber As Long
    7.         dwPlatformId As Long
    8.         szCSDVersion As String * 128      '  Maintenance string for PSS usage
    9. End Type
    10.  
    11. Public Type NetMessageData
    12.    sServerName As String
    13.    sSendTo As String
    14.    sSendFrom As String
    15.    sMessage As String
    16. End Type
    17.  
    18. 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
    19. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    20. Private Const ERROR_ACCESS_DENIED As Long = 5
    21. Private Const ERROR_BAD_NETPATH As Long = 53
    22. Private Const ERROR_INVALID_PARAMETER As Long = 87
    23. Private Const ERROR_NOT_SUPPORTED As Long = 50
    24. Private Const ERROR_INVALID_NAME As Long = 123
    25. Private Const NERR_BASE As Long = 2100
    26. Private Const NERR_Success As Long = 0
    27. Private Const NERR_NetworkError As Long = (NERR_BASE + 36)
    28. Private Const NERR_NameNotFound As Long = (NERR_BASE + 173)
    29. Private Const NERR_UseNotFound As Long = (NERR_BASE + 150)
    30.  
    31.  
    32. Private Const VER_PLATFORM_WIN32s As Long = 0
    33. Private Const VER_PLATFORM_WIN32_WINDOWS As Long = 1
    34. Private Const VER_PLATFORM_WIN32_NT As Long = 2
    35.  
    36. Public Function IsWinNT() As Boolean
    37.     Dim os As OSVERSIONINFO
    38.    
    39.     os.dwOSVersionInfoSize = Len(os)
    40.    
    41.     If GetVersionEx(os) = 1 Then
    42.         IsWinNT = (os.dwPlatformId = VER_PLATFORM_WIN32_NT)
    43.     End If
    44. End Function
    45.  
    46. Public Function NetSendMessage(p_MsgData As NetMessageData) As String
    47.     Dim lngRet As Long
    48.    
    49.     'make sure the user is on NT
    50.     If IsWinNT() Then
    51.         If p_MsgData.sSendTo = "" Then
    52.             NetSendMessage = GetNetSendMessageStatus(ERROR_INVALID_PARAMETER)
    53.             Exit Function
    54.         Else
    55.        
    56.             'if there is a message
    57.             If Len(p_MsgData.sMessage) Then
    58.    
    59.                 'convert the strings to unicode
    60.                 p_MsgData.sSendTo = StrConv(p_MsgData.sSendTo, vbUnicode)
    61.                 p_MsgData.sMessage = StrConv(p_MsgData.sMessage, vbUnicode)
    62.            
    63.                 If Len(p_MsgData.sServerName) > 0 Then
    64.                     p_MsgData.sServerName = StrConv(p_MsgData.sServerName, vbUnicode)
    65.                     Else: p_MsgData.sServerName = vbNullString
    66.                 End If
    67.                        
    68.                 If Len(p_MsgData.sSendFrom) > 0 Then
    69.                     p_MsgData.sSendFrom = StrConv(p_MsgData.sSendFrom, vbUnicode)
    70.                     Else: p_MsgData.sSendFrom = vbNullString
    71.                 End If
    72.            
    73.                 'change the cursor and show. Control won't return
    74.                 'until the call has completed.
    75.                 Screen.MousePointer = vbHourglass
    76.            
    77.                 lngRet = NetMessageBufferSend(p_MsgData.sServerName, p_MsgData.sSendTo, p_MsgData.sSendFrom, p_MsgData.sMessage, ByVal Len(p_MsgData.sMessage))
    78.                 Screen.MousePointer = vbNormal
    79.            
    80.                 NetSendMessage = GetNetSendMessageStatus(lngRet)
    81.             End If
    82.         End If
    83.     End If
    84. End Function
    85.  
    86. Private Function GetNetSendMessageStatus(p_lngError As Long) As String
    87.     Dim strMsg As String
    88.    
    89.     Select Case p_lngError
    90.         Case NERR_Success:            strMsg = "The message was successfully sent."
    91.         Case NERR_NameNotFound:       strMsg = "Send To: user or workstation was not found."
    92.         Case NERR_NetworkError:       strMsg = "A general network error occurred."
    93.         Case NERR_UseNotFound:        strMsg = "The network connection could not be found."
    94.      
    95.         Case ERROR_ACCESS_DENIED:     strMsg = "Access to the computer denied."
    96.         Case ERROR_BAD_NETPATH:       strMsg = "Sent From: server name was not found."
    97.         Case ERROR_INVALID_PARAMETER: strMsg = "Invalid parameter(s) have been specified."
    98.         Case ERROR_NOT_SUPPORTED:     strMsg = "Network request not supported."
    99.         Case ERROR_INVALID_NAME:      strMsg = "Illegal character or malformed name."
    100.  
    101.         Case Else:                    strMsg = "Unknown error executing command."
    102.     End Select
    103.    
    104.     GetNetSendMessageStatus = strMsg
    105. End Function
    Form Code
    VB Code:
    1. Option Explicit
    2. Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    3.  
    4. Private Sub Command1_Click()
    5.     Dim NetMsg As NetMessageData
    6.     Dim strReturn As String
    7.     Dim strCompName As String
    8.     Dim lngRet As Long
    9.    
    10.     strCompName = Space(100)
    11.     lngRet = GetComputerName(strCompName, Len(strCompName))
    12.    
    13.    
    14.     If lngRet = 0 Then Exit Sub
    15.        
    16.        
    17.     strCompName = Left(strCompName, InStr(strCompName, vbNullChar) - 1)
    18.    
    19.     With NetMsg
    20.         .sServerName = strCompName
    21.         .sSendFrom = "Serge"
    22.         .sSendTo = "PCNameToSend"
    23.         .sMessage = "Hello from Net Send"
    24.     End With
    25.    
    26.     strReturn = NetSendMessage(NetMsg)
    27.    
    28.     MsgBox strReturn
    29. End Sub

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