Jump to content

Remote controller


Recommended Posts

I have created this script in order to perform some action on a remote computer: now you can only open windows whit a message inside,for example warning window,start a new prompt window and shutdown the computer.Here is the code:

Client:

CODE
;Created by 4got

#include <GUIConstants.au3>

#include <INet.au3>

#include <TCP Funcs.au3>

;-----------------------Creation of the window-----------------------

GUICreate("Client",250,250,300,300) ;create a window

GUISetState() ;window status visible

;--------------------------------------------------------------------

;-----------------------Inside the window----------------------------

GUICtrlCreateLabel("Receiver:",10,10) ;new label

$input=GUICtrlCreateInput ("0.0.0.0", 60,5) ;input for the ip of the receiver

;------------------------creation of a group of radio button---------

GuiCtrlCreateGroup("Windows", 10, 35,230,100) ;create the new group

$normal=GuiCtrlCreateRadio("Normal", 20, 50, 80) ;and the various radio button for the different tipe of the window

GuiCtrlSetState(-1, $GUI_CHECKED) ;set the first radio button checked

$stop=GuiCtrlCreateRadio("Stop", 20, 70, 80)

$question=GuiCtrlCreateRadio("?", 20, 90, 80)

$exl=GuiCtrlCreateRadio("!", 20, 110, 80)

$info=GuiCtrlCreateRadio("Information", 100, 50, 80)

GUICtrlCreateGroup ("",-99,-99,1,1) ;end of the group

;--------------------------------------------------------------------

$n2 = GUICtrlCreateButton("Send", 10, 220, 60) ;send button

$n3 = GUICtrlCreateEdit("write here the message",10, 140, 230, 70) ;space for the text to send

$n4 = GUICtrlCreateMenu("Command") ;menu'

$n5 = GuiCtrlCreateMenuItem("Start",$n4)

$n6 = GuiCtrlCreateMenuItem("Shutdown",$n4)

;-------------------------begin--------------------------------------------------

GUICtrlSetState(-1, $GUI_FOCUS)

while 1

$msg = GUIGetMsg()

Select

Case $msg=$n2

$ipselected = GUICtrlRead($input, 1) ; the value of the ip

$mess=GUICtrlRead($n3,1) ;read the message

$cont=ping($ipselected) ;ping the addres to determinate if it is online

If $cont Then

TCPStartup()

$Socket=TCPConnect($ipselected,7000) ;connection with the selected ip

;-----control the check box selected

Select

Case BitAND(GUICtrlRead($normal), $GUI_CHECKED) = $GUI_CHECKED

$win=0

Case BitAND(GUICtrlRead($stop), $GUI_CHECKED) = $GUI_CHECKED

$win=16

Case BitAND(GUICtrlRead($question), $GUI_CHECKED) = $GUI_CHECKED

$win=32

Case BitAND(GUICtrlRead($exl), $GUI_CHECKED) = $GUI_CHECKED

$win=48

Case BitAND(GUICtrlRead($info), $GUI_CHECKED) = $GUI_CHECKED

$win=64

EndSelect

TCPSendMessage($Socket,$win & " " & $mess & @CRLF ) ;send the message

TCPCloseSocket($Socket) ;close the connection

TCPShutdown()

Else

MsgBox(48,"ERROR","Host is down") ;if the host is not connected

EndIf

Case $msg=$n5

$mess="start"

$ipselected = GUICtrlRead($input, 1) ; the value of the ip

$cont=ping($ipselected) ;ping the addres to determinate if it is online

If $cont Then

TCPStartup()

$Socket=TCPConnect($ipselected,7000)

TCPSendMessage($Socket,$mess & @CRLF)

TCPCloseSocket($Socket) ;close the connection

TCPShutdown()

EndIf

Case $msg=$n6

$mess="shutdown"

$ipselected = GUICtrlRead($input, 1) ; the value of the ip

$cont=ping($ipselected) ;ping the addres to determinate if it is online

If $cont Then

TCPStartup()

$Socket=TCPConnect($ipselected,7000)

TCPSendMessage($Socket,$mess & @CRLF)

TCPCloseSocket($Socket) ;close the connection

TCPShutdown()

EndIf

Case $msg= $GUI_EVENT_CLOSE

ExitLoop

EndSelect

wend

Server:

CODE

#include <Misc.au3>

#include <TCP Funcs.au3>

#NoTrayIcon

Local $ConnectedSocket = -1

$MainSocket = TCPStartServer(7000) ;open the port 7000

While 1

$ConnectedSocket = TCPAccept( $MainSocket) ;accept entering connection

If $ConnectedSocket > 0 Then

$Data = TCPReceive($ConnectedSocket) ;take the message

if $ConnectedSocket<>-1 Then

Select

Case StringInStr($Data,"start",0) > 0

run("cmd.exe")

Case StringInStr($Data,"shutdown",0) > 0

Shutdown(9)

Case StringInStr($Data,"0",0) > 0

$mess=StringTrimLeft($Data,1)

$win=StringTrimRight($Data,stringlen($Data)-1)

msgbox($win,"Finestra di Windows",$mess)

Case StringInStr($Data,"16",0) > 0

$mess=StringTrimLeft($Data,2)

$win=StringTrimRight($Data,stringlen($Data)-2)

msgbox($win,"Warning",$mess)

Case StringInStr($Data,"32",0) > 0

$mess=StringTrimLeft($Data,2)

$win=StringTrimRight($Data,stringlen($Data)-2)

msgbox($win,"Domanda",$mess)

Case StringInStr($Data,"48",0) > 0

$mess=StringTrimLeft($Data,2)

$win=StringTrimRight($Data,stringlen($Data)-2)

msgbox($win,"Finestra di Windows",$mess)

Case StringInStr($Data,"64",0) > 0

$mess=StringTrimLeft($Data,2)

$win=StringTrimRight($Data,stringlen($Data)-2)

msgbox($win,"Informazione",$mess)

Case Else

MsgBox(0, "Message Received", $Data) ;print the message

EndSelect

EndIf

EndIf

WEnd

Could someone help me to add more stuff to this script ??

THX a lot

Link to comment
Share on other sites

  • 2 weeks later...

Um question, why didn't you put this in example scripts, and what would you like added?

because I've already posted this example in another section and someone told me to post here the script.. I was looking for other functions to add ...for example take a screenshot from the remote computer...something like this
Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...