Reputation: 6488
I have a Telegram account and created Telegram bot to do some actions on remote machines. It works ok. I fixed some codes in the bot and want to update all bots on all computers?
I.e. the bot understands command "/update" but how to pass the new .exe from my computer to all bots and do self-update?
Upvotes: 0
Views: 542
Reputation: 15172
I have also written such a bot with a self-update mechanism.
To Update the bot I just have to send the new .exe over Telegram, but any other method works fine.
Basically, I do the following:
getFile
with the file_id to get the path.On windows, you can't change a .exe while it is running.
I run my bot as windows service, which makes things a bit more complicated, but also easier:
If the bot runs as SYSTEM user, permissions/UAC are not a problem. Otherwise allow the service user to write the executable and start the process.
If you run the program from desktop, then UAC can be a problem: If run as admin, you are fine. Processes started inherit the admin access. If not run as admin... Well the user your bot runs on requires write access to the executable.
Upvotes: 1
Reputation: 1760
You need external script for cmd that will be run by your bot after getting "/update" command. This script should firstly stop your bot and replace .exe files and run new .exe file.
Upvotes: 1