Jump to content
Joachim

[HOW-TO] Bot 24/7 and relaunch on crash

Recommended Posts

[HOW-TO] Bot 24/7 and relaunch on crash

Hello everyone,

 

Let's be honest, if you let the bot run 24/7, at some point it's gonna crash.

I have four bots with 10 villages running non-stop and everyday something random happens: a black window, can't find army window, adbhandle not found,  unavailable sharedfolder, etc.

A simple restart solves it, but running the bot command with /restart is not enough as if it's an emulator failure it won't be solved until you close any emulator process.

 

So I wanted to share how I prevent ANY random issue from happening on my setup.

 

Basically, I relaunch every emulator and bot every three hours + I check every five minutes if a bot is frozen and relaunch if positive. Not manually of course.

 

Script I to launch all bots Start.cmd

Révélation

cd %USERPROFILE%\Desktop\MyBot
start mybot.run.exe ProfileName /restart
timeout 120
start mybot.run.exe ProfileName2 /restart
timeout 120
start mybot.run.exe ProfileName3 /restart
timeout 120
start mybot.run.exe ProfileName4 /restart
exit

 

Script II to get admin rights, kill all the emulators and launch Script I. KillRestart.cmd

Révélation

@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

taskkill /IM Mybot.run.exe /F
taskkill /IM ADB.exe /F
taskkill /IM Memu.exe /F
taskkill /IM MemuHeadless.exe /F
taskkill /IM MemuService.exe /F
taskkill /IM MemuSVC.exe /F
cd %USERPROFILE%\Desktop\MyBot\Scripts
Start start.cmd

 

Script III to get admin rights and kill any hung process and launch Script I if it found a process hanging KillHung.cmd

Révélation

@echo off

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
    IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

cd  %USERPROFILE%\Desktop\MyBot\Scripts
taskkill.exe /f /fi "status eq not responding"
if "%ERRORLEVEL%"=="0"
start killrestart.cmd
else
exit

 

A software to schedule these scripts

I use Z-Cron, you can find it here: https://www.z-cron.com/

It's completely free and very easy to use.

==========================================================

TUTORIAL

 

1. Put Mybot folder on desktop and name it "MyBot"

2. Create a folder named "Scripts" in the MyBot Folder

3. Put all scripts I attached in that folder

4. Modify start.cmd to replace with your own profile names.

5. Install Z-cron

6. Create two jobs in Z.cron with the following settings:

 

Job one, in the box "batchfile", point to killhung.cmd

Job one, check activate task

Job one, in scheduler, select everyday and every 5 minutes

Save job one

 

Job two, in the box "batchfile", point to killrestart.cmd

Job two, check activate task

Job two, in scheduler, select everyday and tick every two hours

Save job two

 

7. In Z-cron, go to program > start > check Z-Cron as an NT service and exit.

================================================================

 

That should be it.

Take the time to read the scripts after the doted line (before that is just to get admin rights) and you'll understand very easily what they do.

 

I hope that will help those of you who, like me, were losing precious botting time.

Don't hesitate in giving rep if it was helpful

 

Cheers

Joachim

 

PS:

And I use another script to load a specific profile without restarting all

I manually modify the config.ini of all my profiles to make sure the right emulator and instance is set so I don't need more argument than the profile name.

Select.cmd

Edited by Joachim
  • Like 5
  • Upvote 1

Share this post


Link to post
Share on other sites

Thank you.

I started this a few days ago, took ten minutes to write it. I can't believe I didn't do that when I started botting.

 

My bots are ALWAYS working now ! Best tweak I ever did for MyBot.

That and tweaking the sleep function to reduce CPU usage by half.

Share this post


Link to post
Share on other sites

My setup is as follows:

1. Put Mybot folder on desktop and name it "MyBot"

2. Create a folder named "Scripts" in the MyBot Folder

3. Put all scripts I attached in that folder

4. Modify CMD to replace with your own profile names.

5. Install Z-cron

6. Create two jobs in Z.cron with the following settings:

 

Job one, in the box "batchfile", point to killhung.cmd

Job one, check activate task

Job one, in scheduler, select everyday and every 5 minutes

Save job one

 

Job two, in the box "batchfile", point to killrestart.cmd

Job two, check activate task

Job two, in scheduler, select everyday and tick every two hours

Save job two

 

6. In Z-cron, go o to program > start > check Z-Cron as an NT service and exit.

 

That should be it.

Take the time to read the scripts after the doted line (before that is just to get admin rights) and you'll understand very easily what they do.

 

 

Share this post


Link to post
Share on other sites

I still confuse something dude..

1. start mybot.run.exe ProfileName /restart 

--> what is the ProfilName mean? Must we change it into something?

 

2. How about if I using Bluestackss,, what KillRestart.cmd should we use? Because ur script is for Memu.

 

Thankyou sir for sharing. Sorry my bad english

start mybot.run.exe ProfileName /restart

okay the script can open the mybot but the bot cant stary by itself

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...