Jump to content

Recommended Posts

Posted (edited)

hi all 

 i had made 2 scripts the first one send a shutdown command to a second script in a another PC  in another network (SENDER)

the other script receives the order and shut down (RECIVER)

SENDER's code

#include <GUIConstantsEx.au3>
GUICreate("", 300,300)
$com = GUICtrlCreateCombo("", 100, 75, 70, 100, 0x0003)
GUICtrlSetData($com, "Shutdown|Reboot|Logoff|Standby|Hibernate")
$but = GUICtrlCreateButton("Send command", 85, 150, 100,50)
GUISetState()
TCPStartup()

While 1
    $nMsg = GUIGetMsg()
    if $nMsg = $GUI_EVENT_CLOSE Then Exit
    if $nMsg = $but Then check()
WEnd

Func check()
    $check = 0
    If  GUICtrlRead($com) = "" Then $check = 1
    if $check = 1 then MsgBox (0, "","Fill it")
    if $check = 0 Then but()
EndFunc


func but()
    $TCPConnect = TCPConnect("82.137.235.81", 555)
    TCPSend ($TCPConnect, GUICtrlRead($com))

EndFunc

reciver's code

TCPStartup()

$TCPListen = TCPListen(@IPAddress1, 555)
Do
$TCPAccept = TCPAccept ($TCPListen)
Until $TCPAccept <> -1
Do
$TCPRecive = TCPRecv ($TCPAccept, 1000000)
Until $TCPRecive <> ""


    $var = 0
    if $TCPRecive = "Shutdown" Then $var = 1
    if $TCPRecive = "Reboot" Then $var = 2
    if $TCPRecive = "Logoff" Then $var = 0
    if $TCPRecive = "Standby" Then $var = 32
    if $TCPRecive = "Hibernate" Then $var = 64
    if $TCPRecive = 1 Then $var = $var + 4
    if $TCPRecive = 4 Then $var = $var

MsgBox(0,"",$var)
;Shutdown($var)

it was working fine when i used @ipadresses in both scripts on the same pc

but when i repalced @ipadresses1 with the public IP (every script on a pc and separate networks)it wont work 

any ideas what i'm missing ?

thanks in advanced

Edited by alexander95

Posted

Public IP means nothing to your receiver script until you you do what's called port forwarding. That's basically translating the adress (and/or ports) from one to another done by your router. Google a bit.

After that you would probably need to adjust firewall settings to allow traffic on port 555 (your script).

♡♡♡

.

eMyvnE

Posted

trancexx

 

 

can u tell me the several things ?

and what is the 0,01 % ?

That's out of the control of the user.

PS: i know i'm too annoying

Actually the only annoying thing is that you link my name to my profile so when I click thinking it's useful link I end up here.

Oh and "u" for "you" is also annoying and "tnx".

...Ehh now that I think about it, you are right.

♡♡♡

.

eMyvnE

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
  • Recently Browsing   0 members

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