uchuuio / disbott

A bot for Discord
https://disbott.uchuu.io
3 stars 1 forks source link

Auto-restart Snippet Implemented #42

Open tomouchuu opened 8 years ago

tomouchuu commented 8 years ago
$loop = 1;
while ($loop)
{
    $process = Start-Process "myBot.exe" -Wait -NoNewWindow -PassThru
    switch ($process.ExitCode)
    {
        0 {"Restarting..."; Start-Sleep -s 3}
        1 {"Exiting."; $loop = 0;}
        default {"Unhandled Exit Code, Exiting."; $loop = 0}
    }
}
# In your bot, you can use Environment.Exit(0) to restart, or Environment.Exit(1) to kill.

Action the above into the script.

This may also help close #23

tomouchuu commented 7 years ago

Auto restart