Jump to content

Execute scripts remotely - help


Aarstad
 Share

Recommended Posts

Hey guys.

Do you know of an already written software that has clients connected to a main server? I am looking for a method to have multiple windows xp 64 bit machines connected to one master server (hopefully one with a login).

When the master server assigns an execute of the autoit script, all the clients should react instantly. It would be best to have it remotely execute scripts, but remotely executing compiled exe files would be great as well.

I have tried searching, but to no avail. The fact is that I think this can be scripted in autoit itself - but i lack the knowledge and experience to code it myself. I use autoit for simple execution on multiple machines that should have the same settings based on what my boss requests me too.

We manually do this by logmein at the moment, but its 200 machines, so it takes forever (even something as tedious as setting X value to new X value).

Link to comment
Share on other sites

I am not an expert so if i am wrong some one please corect me

Lookup

TCPConnect()
TCPSend()
TCPRecv()

in the help file

Then we must be on the same level. I have also read about tcpsend and receive. I also looked at a couple of example scripts that does the job close to what I want it to. However I do not understand how it works, and instead of spending a lot of time learning it i rather have a software that could replicate the expectations.

TCPsend and receive should be set with "array" or something to work with multiple machines, but i am still very confused and i cant seem to grasp it.

Link to comment
Share on other sites

  • Moderators

Regarding whether it can be done purely with AutoIt or not, it depends on your script. Can you please explain further what you would like to do on these machines?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Purely with autoit is by no means necessary. This is the logic:

Client connects to a server (master pc). When server says jump (ie. run exe on dropbox), clients jump.

IP addresses are not preferred, but login details for both server admin and clients are preferred.

Edit: I see I posted this thread in a forum that are questions related to autoit. This might have to be moved to another thread. The question at hand is mostly about a software that allows me to remotely execute scripts i have created with autoit.

Edited by Aarstad
Link to comment
Share on other sites

PSExec

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Is there such a software that allows clients to connect to an ip address, and wait for simple execute commands? I have searched for guides on psexec but none of it makes sense. From what i gathered psexec tries to run scripts by connecting to an ip address. but ip addresses change and when its 200 machines that will become a nightmare..

server on ONE ip address(something.no-ip.org.

X amount of clients connect to the ONE ip address.

ONE ip address has a gui that shows X amount of clients connected.

ONE ip address has the possibility to run exe, batch or autoit scripts on X amount of clients that are connected.

It seems so simple in my head, but I might be explaining this in a terrible way.

Link to comment
Share on other sites

ok here my test script it needs more work but i think it does a part of what you want

Send Command

send_data()

Func send_data()


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

TCPStartup()
Local $cs, $data
Local $ip = "192.168.0.105" ;ip from my local network change to your local ip
Local $port = 33891

$cs = -1

$cs = TCPConnect($ip, $port)

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button1 = GUICtrlCreateButton("Run Notepad", 8, 8, 203, 121)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###


If @error Then
MsgBox(0, "Error", "Error code : " & @error)
Else
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$data = "notepad.exe" ;>>>>the command to send to the server
If @error Or $data = "" Then ExitLoop

TCPSend($cs, BinaryToString($data, 4))
If @error Then ExitLoop

EndSwitch
WEnd
EndIf
EndFunc ;==>send_data

Recive Command

recive_data()

Func recive_data()
Local $ip = "192.168.0.105" ;ip from my local network change to your local ip
Local $port = 33891
Local $cs, $ms
Local $recive

TCPStartup()

$ms = TCPListen($ip, $port)
If $ms = -1 Then Exit

$cs = -1
Do
$cs = TCPAccept($ms)
Until $cs <> -1

While 1
$recive = TCPRecv($cs, 2048)
If @error Then ExitLoop
$recive = BinaryToString($recive, 4)

If $recive <> "" Then Run($recive) ;>>>>The command to execute (command recived)
WEnd

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

TCPShutdown()

EndFunc ;==>recive_data

Sorry if my english is not 100%

Edited by HeavenlyDemon
Link to comment
Share on other sites

Hey guys.

Do you know of an already written software that has clients connected to a main server? I am looking for a method to have multiple windows xp 64 bit machines connected to one master server (hopefully one with a login).

When the master server assigns an execute of the autoit script, all the clients should react instantly. It would be best to have it remotely execute scripts, but remotely executing compiled exe files would be great as well.

I have tried searching, but to no avail. The fact is that I think this can be scripted in autoit itself - but i lack the knowledge and experience to code it myself. I use autoit for simple execution on multiple machines that should have the same settings based on what my boss requests me too.

We manually do this by logmein at the moment, but its 200 machines, so it takes forever (even something as tedious as setting X value to new X value).

You can you WMI in autoit script.

$objWMIService = ObjGet("winmgmts://" & $server & "/root/cimv2")

......

Link to comment
Share on other sites

ok here my test script it needs more work but i think it does a part of what you want

Send Command

send_data()

Func send_data()


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

TCPStartup()
Local $cs, $data
Local $ip = "192.168.0.105" ;ip from my local network change to your local ip
Local $port = 33891

$cs = -1

$cs = TCPConnect($ip, $port)

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button1 = GUICtrlCreateButton("Run Notepad", 8, 8, 203, 121)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###


If @error Then
MsgBox(0, "Error", "Error code : " &amp; @error)
Else
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$data = "notepad.exe" ;>>>>the command to send to the server
If @error Or $data = "" Then ExitLoop

TCPSend($cs, BinaryToString($data, 4))
If @error Then ExitLoop

EndSwitch
WEnd
EndIf
EndFunc ;==>send_data

Recive Command

recive_data()

Func recive_data()
Local $ip = "192.168.0.105" ;ip from my local network change to your local ip
Local $port = 33891
Local $cs, $ms
Local $recive

TCPStartup()

$ms = TCPListen($ip, $port)
If $ms = -1 Then Exit

$cs = -1
Do
$cs = TCPAccept($ms)
Until $cs <> -1

While 1
$recive = TCPRecv($cs, 2048)
If @error Then ExitLoop
$recive = BinaryToString($recive, 4)

If $recive <> "" Then Run($recive) ;>>>>The command to execute (command recived)
WEnd

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

TCPShutdown()

EndFunc ;==>recive_data

Sorry if my english is not 100%

Interesting.. I can definitely modify this a bit and tweak it to my liking. Many thanks for this!! I am sorry for replying so late, but I did not get a response e mail from this. Again much thanks!
Link to comment
Share on other sites

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...