Kaseya Community


The place to find product documentation, user guides, video demos, and scripts/procedures shared within the community


Scripts - Agent Service Remote Restart

To download, right click the file name in the post to  save the linked xml file.

This script was created to quickly resolve agents that go offline due to the Kaseya Agent crashing. To use execute the script on a online computer in the same network and you will be prompted for the "Target Machine name or IP Address" enter the name or IP address and script will attempt to remotely restart the agent service.

Script will fail if the server is offline and should no take longer then 5min if successful for the offline agent to come back online. If the offline agent does not come back online within 5min review the Agent Procedure/Script logs on the computer you run the script from to get more information. This script can be easily modified to target a specific machine for machines that agent issue that goes offline often.


Please rate and leave comments Smile

  • Scripts - Agent Service Remote Restart

    use pstools (psexec \\PC name) with a batch file that runs sc stop service name sc start service name


    @echo off

    sc stop ka####     ;;<<< Put your service name in place of ka#### it should be your kaseya id with a number

    sc start ka#####

    save the above as .bat file, and use pstools:

    psexec \\pc-name -d -i -c krestart.bat c:\drestart.bat

    that should restart remotely, if you're wanting to restart all kservices on network, psexec \\*

    if you want just a list put then into a file and use psexec @filename

  • Scripts - Agent Service Remote Restart

    Hey there,

    the xml file is to import it as script into the kaseya server?

    when i try this i get this error message:

    The IF statement ¿½ï¿½ is not valid.

    What do i have to do to make it work?

    Thanks for the xml and your help.



  • Scripts - Agent Service Remote Restart


    i´m not a pro at those things.

    So i have to make one batch file?

    But in this line are 2 batch files mentioned:

    psexec \\pc-name -d -i -c krestart.bat c:\drestart.bat

    krestart.bat and c:\drestart.bat

    I think i´m  not understanding your comment, could you please explain it to me in detail if you have time?

    Thanks to you :)



  • Scripts - Agent Service Remote Restart


    its working, thankyou!

  • Scripts - Agent Service Remote Restart

    I always enjoyed this paradox about restarting the agent from a script.. :)

    here's my latest  (batch file)

    # creates a scheduled task to restart the agent service in 2 minutes (only works when the minutes are 57 or less)

    set h=%TIME:~0,2%

    set m=%TIME:~3,2%

    set /a m2="m+2"

    set t2=%h%:%m2%

    set t2

    set d2=%DATE:~4,10%

    set d2

    echo net stop [agent service name]  >C:\ktemp\restartagent2.bat

    echo net start [agent service name] >>c:\ktemp\restartagent2.bat

    schtasks /create /tn "Kaseya Agent Restart" /tr c:\ktemp\restartagent2.bat /sc once /st %t2% /sd %d2% /ru SYSTEM /F