|
1 | | -.. _autostart_windows: |
2 | | - |
3 | | -============================================== |
4 | | -Setting up auto-restart using batch on Windows |
5 | | -============================================== |
6 | | - |
7 | | -.. note:: This guide assumes that you already have a working Red instance. |
8 | | - |
9 | | ------------------------ |
10 | | -Creating the batch file |
11 | | ------------------------ |
12 | | - |
13 | | -Create a new text document anywhere you want to. This file will be used to launch the bot, so you may want to put it somewhere convenient, like Documents or Desktop. |
14 | | - |
15 | | -Open that document in Notepad, and paste the following text in it: |
16 | | - |
17 | | -.. code-block:: batch |
18 | | - |
19 | | - @ECHO OFF |
20 | | - :RED |
21 | | - CALL "%userprofile%\redenv\Scripts\activate.bat" |
22 | | - python -O -m redbot <your instance name> |
23 | | -
|
24 | | - IF %ERRORLEVEL% NEQ 0 ( |
25 | | - ECHO Restarting Red... |
26 | | - GOTO RED |
27 | | - ) |
28 | | -
|
29 | | -Replace ``<your instance name>`` with the instance name of your bot. |
30 | | -If you created your VENV at a location other than the recommended one, replace ``%userprofile%\redenv\Scripts\activate.bat`` with the path to your VENV. |
31 | | - |
32 | | -Click "File", "Save as". Change the dropdown "Save as type" to "All Files (*.*)". Set the filename to ``start_redbot.bat``, and click save. |
33 | | - |
34 | | -There should now be a new file in the location you created the text document in. You can delete that text document as it is no longer needed. |
35 | | -You can now use the ``start_redbot.bat`` batch file to launch Red by double clicking it. |
36 | | -This script will automatically restart red when the ``[p]restart`` command is used or when the bot shuts down abnormally. |
37 | | - |
38 | | -------------------------- |
39 | | -Launch the bot on startup |
40 | | -------------------------- |
41 | | - |
42 | | -Create a shortcut of your ``start_redbot.bat`` file. |
43 | | - |
44 | | -Open the "Run" dialogue box using Windows Key + R. |
45 | | - |
46 | | -Enter ``shell:startup`` if you want the bot to launch only when the current user logs in, or ``shell:common startup`` if you want the bot to launch when any user logs in. |
47 | | - |
48 | | -Drag the shortcut into the folder that is opened. The bot will now launch on startup. |
| 1 | +.. _autostart_windows: |
| 2 | + |
| 3 | +============================================== |
| 4 | +Setting up auto-restart using batch on Windows |
| 5 | +============================================== |
| 6 | + |
| 7 | +.. note:: This guide assumes that you already have a working Red instance. |
| 8 | + |
| 9 | +----------------------- |
| 10 | +Creating the batch file |
| 11 | +----------------------- |
| 12 | + |
| 13 | +Create a new text document anywhere you want to. This file will be used to launch the bot, so you may want to put it somewhere convenient, like Documents or Desktop. |
| 14 | + |
| 15 | +Open that document in Notepad, and paste the following text in it: |
| 16 | + |
| 17 | +.. code-block:: batch |
| 18 | + |
| 19 | + @ECHO OFF |
| 20 | + :RED |
| 21 | + CALL "%userprofile%\redenv\Scripts\activate.bat" |
| 22 | + python -O -m redbot <your instance name> |
| 23 | +
|
| 24 | + IF %ERRORLEVEL% NEQ 0 ( |
| 25 | + ECHO Restarting Red... |
| 26 | + GOTO RED |
| 27 | + ) |
| 28 | +
|
| 29 | +Replace ``<your instance name>`` with the instance name of your bot. |
| 30 | +If you created your VENV at a location other than the recommended one, replace ``%userprofile%\redenv\Scripts\activate.bat`` with the path to your VENV. |
| 31 | + |
| 32 | +Click "File", "Save as". Change the dropdown "Save as type" to "All Files (*.*)". Set the filename to ``start_redbot.bat``, and click save. |
| 33 | + |
| 34 | +There should now be a new file in the location you created the text document in. You can delete that text document as it is no longer needed. |
| 35 | +You can now use the ``start_redbot.bat`` batch file to launch Red by double clicking it. |
| 36 | +This script will automatically restart red when the ``[p]restart`` command is used or when the bot shuts down abnormally. |
| 37 | + |
| 38 | +------------------------- |
| 39 | +Launch the bot on startup |
| 40 | +------------------------- |
| 41 | + |
| 42 | +Create a shortcut of your ``start_redbot.bat`` file. |
| 43 | + |
| 44 | +Open the "Run" dialogue box using Windows Key + R. |
| 45 | + |
| 46 | +Enter ``shell:startup`` if you want the bot to launch only when the current user logs in, or ``shell:common startup`` if you want the bot to launch when any user logs in. |
| 47 | + |
| 48 | +Drag the shortcut into the folder that is opened. The bot will now launch on startup. |
0 commit comments