Jump to content

Invoke AutoIt script over local network

Go to solution Solved by ViciousXUSMC,

Recommended Posts



I have a troublesome QuickBooks server that often needs Quickbooks restarted, what would you guys recommend as the easiest user friendly method of implementing this feature? I would need to send instructions to some less capable staff.


Best regards,



Link to post
Share on other sites
  • Solution
Posted (edited)
taskkill /s remoteServer  /u userName /FI "IMAGENAME eq filename"

Something to that extent can remotely kill the process if you have admin rights

You can use Autoit to create a nice GUI so they can supply the credentials, but it can easily be done just in .bat file as well.


Then on the remote machine, use Autoit to create some kind of Daemon that checks if the process is running and if not restarts it.

Better yet, find a way to completely resolve the issue on the local machine rather than needing any remote interaction at all.


Look at things like what changes when its in the "crashed" state, what kind of breadcrumb can you follow, like CPU usage, RAM usage, A service not responding, etc.


....and of course if you can get to the root cause and prevent it from crashing at all, that would be most ideal.


Here is something I wrote for the helpdesk to restart the print spooler for a users computer that lets them use an AD search to find the computer and remotely restart the service.


#Include <AD.au3>
#Include <File.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <ExtMsgBox.au3>
#include <Array.au3>
#include <Services.au3>

HotKeySet("{ESC}", "_Terminate") ;Set ESC Key to Force Exit Program If Remote Computer Hangs

Global $sINI = @ScriptDir & "\Config_StartServiceRemote.ini"

If NOT FileExists($sINI) Then ;See if our configuration file exist, if not create it
    IniWrite($sINI, "CONFIG", "RemoteService", "spooler")
    IniWrite($sINI, "CONFIG", "ShowSplash", "1")
    IniWrite($sINI, "CONFIG", "Debug", "0")

Global $iDebug = INIRead($sINI, "CONFIG", "Debug", "0") ; Set 0 for Normal Operation, Set 1 to See Debug Information
Global $sService = INIRead($sINI, "CONFIG", "RemoteService", "spooler") ;Global Varible for Service we want to work with
Global $iSplash = INIRead($sINI, "CONFIG", "ShowSplash", "1") ;Global Varible to Show or Hide Status Messages 0 Off 1 On

$sPCN = InputBox("IIO Automation - Find Computer By PCN", "Input PCN To Search For", "") ;Ask user to input a PCN Value
If @Error = 1 Then Exit
$sResult = ""

_AD_Open() ;Open Connection To AD
GLOBAL $sOU = "OU=*snip*" ;Define a Specific OU To Search In
GLOBAL $aObjects[0][0] ;Define The Array To Store Results
$aObjects = _AD_GetObjectsInOU("", "(&(objectclass=computer)(sAMAccountName=*" & $sPCN & "*))", 2, "sAMAccountName") ;AD Query Searching for Computers and A Description Starting With X
If @error > 0 Then ;If We Have No Results
    MsgBox(64, "Active Directory", "No Results Found or Bad Query") ;Show Error Message
    For $i = 1 To $aObjects[0]
        $aObjects[$i] = StringTrimRight($aObjects[$i], 1)
_AD_Close() ;Close Connection to AD

If $aObjects[0] > 3 Then $aObjects[0] = 4 ;If element count is more than 4 than it will be reduced to only 4
If $iDebug = 1 then _ArrayDisplay($aObjects)
$sObjects = _ArrayToString($aObjects, "|", 1, $aObjects[0]) ;This moves the array into a string for use as buttons; uses the element count to determin how many buttons
If $iDebug =1 Then MsgBox("Show Array", "", $sObjects)

_ExtMsgBoxSet(1, 2, 0x004080, 0xFFFF00, 10, "Comic Sans MS", 1000, 1200) ;Set our message box global style
$sMsg = "Click The Computer You Want To Connect To"
$iRetValue = _ExtMsgBox($EMB_ICONEXCLAM, $sObjects, "Found Computers by PCN", $sMsg, 0)
If @Error Then MsgBox(0, "There Was An Error Code Returned", @Error)
ConsoleWrite("Test 3 returned: " & $iRetValue & @CRLF)
If $iRetValue = 0 Then Exit
; Reset to default
If $iDebug = 1 Then MsgBox(0, "Computer Chosen", $aObjects[$iRetValue])
$sComputerName = $aObjects[$iRetValue]
$sComputerIP = TCPNameToIP($aObjects[$iRetValue])
If $iDebug = 1 Then MsgBox(0, "Computer IP", $sComputerIP)
;Returns Are $aObjects[$iRetValue] for Computer Name and $sComputerIP for IP Address

$aStatus = _Service_QueryStatus($sService, $sComputerName)
If $iDebug = 1 Then _ArrayDisplay($aStatus)

If $aStatus[1] = $SERVICE_RUNNING Then
    $iResponce = MsgBox($MB_YESNO, "IIO Automation", "Service " & $sService & " Is Already Running" & @CRLF & "Try To Restart?")
    If $iResponce = $IDYES Then


Func _RestartServiceX()
    _Service_Stop($sService, $sComputerName)
    If $iSplash =1 Then SplashTextOn("IIO Automation", "Stopping " & $sService & " Service" & @CRLF & "Press Escape To Cancel", 500, 100)
        $aStatus = _Service_QueryStatus($sService, $sComputerName)
    Until $aStatus[1] = $SERVICE_STOPPED

Func _StartServiceX()
    _Service_Start($sService, $sComputerName)
    If $iSplash = 1 Then SplashTextOn("IIO Automation", "Starting " & $sService & " Service" & @CRLF & "Press Escape To Cancel", 500, 100)
        $aStatus = _Service_QueryStatus($sService, $sComputerName)
    Until $aStatus[1] = $SERVICE_RUNNING
    MsgBox($MB_OK, "IIO Automation", $sService & " Service Has Been Started on " & $sComputerName)

Func _Terminate()


Edited by ViciousXUSMC
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...