cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Anonymous
Not applicable
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
#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
#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:
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.
13 REPLIES 13
elson_ricafrent
Engaged Sweeper
Can you be more specific on how to deploy this action? I followed the procedure but still not working.

In send.au3, when I compiled it and ran, this is the error "Line2270 (File

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded."

thanks!
jacobsenm
Engaged Sweeper III
Well, if you have a spare minute it would be nice to implement it.
As I see it, before a user will be remote controlled, we could first "talk" if the user has time to be remote controlled.
As it is now, you can send a note, but you do not really get a response back.

Thanks for the assist.
Anonymous
Not applicable
Thanks for the feedback, I've removed that line from the first post, I don't know how it went there 😉
It's not that hard to implement the reply part, but I don't really need it...

Regards,
Paulo
jacobsenm
Engaged Sweeper III
Thank you !

I figured it out. It was the line: "=============================="
in the receive.au3 that caused the issue.
Howver the complition did not complain on that.

It works now as expected.
My only comment is that it would be nice that the end-user should be able to reply back.
For the rest: Nice job !

Regards
Anonymous
Not applicable
as I told before, send.exe expects a hostname as parameter, the error is expected if you don't pass a parameter. Just test it with:
receive.exe | send.exe hostname

you can test this in your own computer, just use your computername as hostname, it should work, then you make the custom action with {computer} as parameter.
jacobsenm
Engaged Sweeper III
Hi BullGates !

Good job
I am interested in this custom action.
I have downloaded and installed AutoIT.
I complied the sources to .exe files.

However, it does not work.
I tried manually to run receive.exe and it comes with error message:
Line -1: Error: Unable to parse line.

I have no experience with autoit, but the compilation went successfully.


When I try the custom action, I can see that receive is being copied.
and the dos screen stays open.

Nothing happens now.
On the remote computer the "receive.exe" process is running in the tasklist, but there is no window that the user can type anything.

Any ideas what can be wrong ?

Thanks

Anonymous
Not applicable
othuRC:
send.exe expects a parameter, if you don't use the right syntax you'll get that error. Make sure you use the action as mentioned on the first post.

dayron:
For all domain you'll have to use net send, and have the needed service running. I've made this to send to a particular computer as a simple way to contact the logged in user.
othuRC
Engaged Sweeper
Hi, i get an error from the send.exe:

Line-1:

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.



How can i fix this?

Regards
dayron
Engaged Sweeper III
I'm going to try this out. Any way of sending a message to all computers in a domain?

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now