I need to set this bot in a windows vps. My bot works fine in a local host but I need to put it in a vps and run it every 12 hours. I don't know how to do it exactly, I am new to servers.
I have searched a lot but couldn't find anything helpful at least on windows. Thanks in advance.
1 - If nodejs isn't installed on the VPS, install it.
2 - In the command line / powershell on your Windows VPS, write node -v
press enter, if this gives an error press windows + R
keys, write rundll32 sysdm.cpl,EditEnvironmentVariables
, in the new window, under 'User variables for ...' select Path and click edit and add the nodejs install directory, press OK. Then close and re-open command line / powershell, to check nodejs again.
2 - Create a test.bat
file and enter the following contents using Notepad/Notepad++ :
cd D:\codework\test\
node index.js
echo finished
3 - Press windows + R
keys, write taskschd.msc
to open Task Scheduler, then go to Actions > Create a basic task,
check names
then ok.test.bat
file, under *Start in(optional) : enter the directory where the test.bat is (note: this is optional but on some systems the file doesn't run without this part)4 - On the Actions panel on the right, there is a 'Enable All Tasks History' enable it, to see task results / errors in the History tab.
5 - Lastly : You can also select and run the task manually.