0
  1. I have the following python file, which simply:

    • connects to telegram bot
    • waits for command ("\s" or "\screenshot") and then sends time + screenshot
  2. 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.

  3. The problem appears then I move the file to the StartUp Windows Folder:

    C:\Users\Elliot\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartUp

  4. 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()
Zucker
  • 53
  • 6
  • Duplicate question https://stackoverflow.com/questions/4438020/how-to-start-a-python-file-while-windows-starts – Hans Mar 09 '21 at 15:08
  • I tried with the shortcut and the message is still appearing ... – Zucker Mar 09 '21 at 15:49
  • You said that you are using pyinstaller to create an exe but then you said that there is error with "filename.py" - there's something not right here. Another issue with autostart - offten network is not available right now and you have to wait a couple of seconds or your script may fail. – viilpe Mar 10 '21 at 20:17

0 Answers0