Jump to content

Server to run a autoit script from another pc


Recommended Posts

  • Moderators

The easiest option is PSExec. Be aware, if you're doing something that relies on Send or MouseClick, or a GUI, you are going to have a difficult time of it.

"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

1 hour ago, JLogan3o13 said:

The easiest option is PSExec. Be aware, if you're doing something that relies on Send or MouseClick, or a GUI, you are going to have a difficult time of it.

thanks man but I was think of sending requests from a server and then when the script gets the request it runs the rest of the script.

don't know how to explain it but I think it could be done never played with this kinda stuff pretty solid programmer tho anyways thanks again.

Edited by PleaseHelpMEIWillLoveyou
Link to comment
Share on other sites

You can request data, or text files from the server and run the result. OR a simple scenario is for example PC1 has a shared folder with a txt file, the script on the server in the middle of the script downloads it and runs it. PC2 has another script - the script on the server in the middle of the script downloads it and runs it. Something like that.

Link to comment
Share on other sites

On 7/5/2018 at 2:08 AM, Juvigy said:

You can request data, or text files from the server and run the result. OR a simple scenario is for example PC1 has a shared folder with a txt file, the script on the server in the middle of the script downloads it and runs it. PC2 has another script - the script on the server in the middle of the script downloads it and runs it. Something like that.

yea man, do you have a clue how to do this or something will be greatly appreciated. 

Link to comment
Share on other sites

Maybe if you will use the send and received method that can solve your problem. Let's say something like sending a txt file on a shared folder as what Juvigy said.

How?

1. PC1, create a script that will send a text file on that specific shared folder with 0mb.

2. PC2, create a script that will loop to that shared folder looking for the specific text file using FileFindFirstFile() and FileFindNextFile().

3. Once the script in PC2 find the specific text file, then it will run and you should directly delete the text file before the whole script run (else it will loop back many times).

Or,

I suggest search for chat script in this forum and you will see what I mean. Chat script has the same scenario as I stated above.^_^

 

Here's a sample script where you can start with.

PC1 script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "Terminate")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("PC1", 150, 80, 300, 200)
$Button1 = GUICtrlCreateButton("Send", 16, 20, 81, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
               $logPath = "\\10.0.0.0\Shared\Test\"
               $info = MsgBox(4, "Sending Command in PC2", "This is just a confirmation!")
               If $info = 6 Then
                  $hFile = FileOpen($logPath & "Test.log", 1)
                  FileWriteLine($hFile, "")
                  FileClose($hFile)
                  Exit
               Else
                 Exit
               EndIf
    EndSwitch
WEnd

 

PC2 script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUISetState(@SW_HIDE) ; this will hide the process...

While 1
   Sleep(1000)
   Example()
WEnd
Func _RemoveFileExt($string)
    Return StringLeft($string,StringInStr($string,".",Default,-1)-1)
EndFunc
Func Example()
    $LogPath = "\\10.0.0.0\Shared\Test\*" ; this is you shared folder
    Local $hSearch = FileFindFirstFile($LogPath)
    $sFileName = FileFindNextFile($hSearch)
    If FileExists($LogPath & ".log") Then
       FileDelete("\\10.0.0.0\Shared\Test\" & $sFileName)
       $Form2 = GUICreate("PC2", 160, 100, 200, 124)
       $Button1 = GUICtrlCreateButton("Click Me", 16, 20, 81, 33)
       GUISetState(@SW_SHOW)
        While 1
         Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
               Exit
            Case $Button1
               MsgBox(0,"",$sFileName)
         EndSwitch
        WEnd
    EndIf
EndFunc

 

If that's what you want.:)

Edited by KickStarter15
Added sample code.

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

On 7/7/2018 at 12:12 AM, KickStarter15 said:

Maybe if you will use the send and received method that can solve your problem. Let's say something like sending a txt file on a shared folder as what Juvigy said.

How?

1. PC1, create a script that will send a text file on that specific shared folder with 0mb.

2. PC2, create a script that will loop to that shared folder looking for the specific text file using FileFindFirstFile() and FileFindNextFile().

3. Once the script in PC2 find the specific text file, then it will run and you should directly delete the text file before the whole script run (else it will loop back many times).

Or,

I suggest search for chat script in this forum and you will see what I mean. Chat script has the same scenario as I stated above.^_^

 

Here's a sample script where you can start with.

PC1 script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "Terminate")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("PC1", 150, 80, 300, 200)
$Button1 = GUICtrlCreateButton("Send", 16, 20, 81, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
               $logPath = "\\10.0.0.0\Shared\Test\"
               $info = MsgBox(4, "Sending Command in PC2", "This is just a confirmation!")
               If $info = 6 Then
                  $hFile = FileOpen($logPath & "Test.log", 1)
                  FileWriteLine($hFile, "")
                  FileClose($hFile)
                  Exit
               Else
                 Exit
               EndIf
    EndSwitch
WEnd

 

PC2 script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUISetState(@SW_HIDE) ; this will hide the process...

While 1
   Sleep(1000)
   Example()
WEnd
Func _RemoveFileExt($string)
    Return StringLeft($string,StringInStr($string,".",Default,-1)-1)
EndFunc
Func Example()
    $LogPath = "\\10.0.0.0\Shared\Test\*" ; this is you shared folder
    Local $hSearch = FileFindFirstFile($LogPath)
    $sFileName = FileFindNextFile($hSearch)
    If FileExists($LogPath & ".log") Then
       FileDelete("\\10.0.0.0\Shared\Test\" & $sFileName)
       $Form2 = GUICreate("PC2", 160, 100, 200, 124)
       $Button1 = GUICtrlCreateButton("Click Me", 16, 20, 81, 33)
       GUISetState(@SW_SHOW)
        While 1
         Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
               Exit
            Case $Button1
               MsgBox(0,"",$sFileName)
         EndSwitch
        WEnd
    EndIf
EndFunc

 

If that's what you want.:)

Thank you soo much Man Your the best!

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

×
×
  • Create New...