Home | Download | Demo | Feature list | Premium users | Support | Knowledgebase
How to fix WMI Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
The network path was not found - The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
How to configure Windows Vista clients.
How to configure the windows firewall using group policies.
   
Welcome Guest Search | Active Topics | Members | Log In | Register

My "net send" substitute Options
BullGates
Posted: Monday, March 31, 2008 11:15:44 PM

Rank: Premium user
Groups: Member , Premium Users

Joined: 9/29/2007
Posts: 48
Location: PT
Well, on our environment we don't have the messenger service enabled at all, so it may be hard to comunicate with the user of a computer. With some AutoIT scripting and Lansweeper it's quite easy to manage a solution. Here it is, a custom action to do it...

send.au3
Code:
#include <GUIConstants.au3>
Opt("TrayIconHide", 1)

TCPStartup()
Dim $szServerPC = $cmdline[1]
Dim $szIPADDRESS = TCPNameToIP($szServerPC)
Dim $nPORT = 5555
Dim $ConnectedSocket = -1

While $ConnectedSocket = -1
    $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)
WEnd

Dim $szData

If @error Then
    MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error)
Else
    While 1
        $szData = InputBox("My NetSender!", @LF & @LF & "Enter text to send to " & $cmdline[1] & "(" & $szIPADDRESS & "):")
        $szData = $szData

        If @error Or $szData = "" Then ExitLoop

        TCPSend($ConnectedSocket, $szData)

        If @error Then ExitLoop
    WEnd
EndIf


receive.au3
Code:
#include <GUIConstants.au3>
#include <Constants.au3>
Opt("TrayIconHide", 1)

Dim $szIPADDRESS = @IPAddress1
Dim $nPORT = 5555
==============================
TCPStartUp()

$MainSocket = TCPListen($szIPADDRESS, $nPORT)

If $MainSocket = -1 Then Exit

Dim $ConnectedSocket = -1

Do
    $ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket <> -1

Dim $szIP_Accepted = SocketToIP($ConnectedSocket)

Dim $msg, $recv

While 1
   $msg = GUIGetMsg()
   $recv = TCPRecv( $ConnectedSocket, 2048 )

    If @error Then ExitLoop

if $recv <> "" Then MsgBox(262208,"Message",$recv)

WEnd


If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket )

TCPShutDown()

Func SocketToIP($SHOCKET)
    Local $sockaddr = DLLStructCreate("short;ushort;uint;char[8]")

    Local $aRet = DLLCall("Ws2_32.dll","int","getpeername","int",$SHOCKET, _
            "ptr",DLLStructGetPtr($sockaddr),"int_ptr",DLLStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
        $aRet = DLLCall("Ws2_32.dll","str","inet_ntoa","int",DLLStructGetData($sockaddr,3))
        If Not @error Then $aRet = $aRet[0]
    Else
        $aRet = 0
    EndIf

    $sockaddr = 0

    Return $aRet
EndFunc


compile both scripts, you'll need psexec.exe as well, and use the following custom action commands on Lansweeper console:
Code:
cmd.exe /K \\server\share$\Lansweeper\psexec.exe \\{computer} -c -s -i \\server\share$\Lansweeper\receive.exe | \\server\share$\Lansweeper\send.exe {computer}


Well not much science on this one, but it works as expected so far, and doesn't depend on the annoying messenger service.
76012
Posted: Monday, April 21, 2008 4:48:53 PM

Rank: Premium user
Groups: Member , Premium Users

Joined: 2/7/2008
Posts: 31
Nice! I notice Receive.exe does not exit until the remote user clicks the OK button. That's helpful to know they acknowledged your text, but not so much if you just want to leave a message on their screen...

Thanks for sharing.
BullGates
Posted: Monday, April 21, 2008 5:40:39 PM

Rank: Premium user
Groups: Member , Premium Users

Joined: 9/29/2007
Posts: 48
Location: PT
Yes it's like you said, but that's not a problem either, if you close the send.exe the message will still be there on the remote computer until someone clicks ok... so it works as expected in my opinion. ;-)
tdewar@leakeandwatts.org
Posted: Monday, September 22, 2008 5:56:27 PM

Rank: Premium user
Groups: Member , Premium Users

Joined: 9/18/2008
Posts: 16
Location: New York
Does this script still work with the latest version of Auto IT? I tried to use it and I seem to be getting compiling errors.
trs
Posted: Thursday, October 09, 2008 4:38:37 PM

Rank: Premium user
Groups: Member , Premium Users

Joined: 7/29/2008
Posts: 2
thanks for sharing worked veary well
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.

   
Quick links: Download - Premium users - Support 
Copyright 2004 - 2008 © Geert Moernaut - Hemoco bvba - All rights reserved