I'm using the windowed flag

I made a program, and turned it into a .exe file. When I use the --windowed flag to hide the command prompt for the user my virus and threat protection doesn’t allow me to download the file. I’m aware that I can whitelist the file to Microsoft, but let’s say I wouldn’t do this, would the user and myself included have to turn off virus protection in order to use this program?

1 Like

What’s the downside of whitelisting it with Microsoft?

Unrecognized executable files that are often blocked, even if they’re completely legitimate.

Yes, but I think that the only solution to allow this program to be downloadable is if I submit it to Microsoft as a false positive. Without doing this though the only way someone could use this program would be to turn off their antivirus protection correct?

This might sound like a copout, but it’s really hard to give a definitive answer without knowing what your code is doing.

Windows Defender has a lot of heuristics that it uses to determine if something is safe or not - the kind of things your code is doing, the APIs its using, if it’s trying to ‘hide’ itself or not, etc.

Here is my code if it helps:

import turtle
import random
import pygame
import tkinter as tk
import os
import sys
turtle.hideturtle()
turtle.penup()
instruct = turtle.Turtle()
instruct.hideturtle()
instruct.penup()
high = turtle.Turtle()
high.hideturtle()
high.penup()
tap = turtle.Turtle()
tap.hideturtle()
num = turtle.Turtle()
num.hideturtle()
count = 0
rando = 2
state = "playing"
key_pressed = None
if getattr(sys, 'frozen', False):
    app_dir = sys._MEIPASS
else:
    app_dir = os.path.dirname(os.path.abspath(__file__))
for r,d,f in os.walk("c:\\"):
    for files in f:
         if files == "high_score.txt":
              high_score_file = os.path.join(r,files)
high_score_file = os.path.join(app_dir, "high_score.txt")
for r,d,f in os.walk("c:\\"):
    for files2 in f:
         if files2 == "Recording.wav":
              sound_file = os.path.join(r,files2)
pygame.init()
def load_high_score():
    if os.path.exists(high_score_file):
        with open(high_score_file, "r") as file:
            return int(file.read().strip())
    else:
        return 0
def save_high_score(score):
    with open(high_score_file, "w") as file:
        file.write(str(score))
score = load_high_score()
instruct.goto(-150, 200)
instruct.write('Instructions: Pressing "Enter" adds 1 to the starting score of\n0, and each number reflects the percentage of potential loss.\nGoal: Get the highest number possible.')
high.goto(0, 100)
high.write('Highscore: ' + str(score), align='center', font=('Comic Sans MS', 30))
def play_sound(sound_file):
    pygame.mixer.init()
    pygame.mixer.music.load(sound_file)
    pygame.mixer.music.play()
def click(x, y):
    global count, state
    if state == "playing":
        if -100 <= x <= 100 and -100 <= y <= 100:
            count += 1
            rando = random.randint(1, 100)
            turtle.hideturtle()
            circle_number(count)
            tap.clear()
            if rando <= count:
                state = "lost"
                turtle.goto(0, -150)
                turtle.write('You Lost!', align='center', font=('Comic Sans MS', 30))
                turtle.onscreenclick(None)
                play_sound(sound_file)
                turtle.goto(-100, -200)
                turtle.fillcolor('#03fc2c')
                rectangle(200, 50)
                turtle.goto(0, -240)
                turtle.write('Retry', align='center', font=('Fixedsys', 30))
                check_high_score()
def check_high_score():
    global count, score
    if count > score:
        score = count
        save_high_score(score)
        high.clear()
        high.write('Highscore: ' + str(score), align='center', font=('Comic Sans MS', 30))
def click2(x, y):
    global count, state
    if state == "lost" and -100 <= x <= 100 and -25 <= y <= 25:
        state = "playing"
        num.clear()
        count = 0
        circle()
def circle():
    turtle.tracer(0)
    turtle.hideturtle()
    turtle.goto(0, 0)
    turtle.dot(200, 'Red')
    turtle.color('Black')
    tap.goto(0, -30)
    tap.write('Tap!', align='center', font=('Ink Free', 30))
    turtle.hideturtle()
def circle_number(number):
    circle()
    num.goto(0, -30)
    num.write(number, align='center', font=('Ink Free', 30))
    turtle.update()
def rectangle(width, height):
    turtle.begin_fill()
    for _ in range(2):
        turtle.forward(width)
        turtle.right(90)
        turtle.forward(height)
        turtle.right(90)
    turtle.end_fill()
    
def exit_fullscreen():
    screenTk.attributes("-fullscreen", False)
    screen.setup(width=800, height=600, startx=100, starty=100)
def key_press_escape():
    global key_pressed
    key_pressed = "Escape"
    if key_pressed == "Escape":
        exit_fullscreen()
def on_close():
    pygame.mixer.quit()
    turtle.bye()
screen = turtle.Screen()
screen_width = screen.window_width()
screen_height = screen.window_height()
root = tk.Toplevel()
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
root.destroy()
window_width = 500
window_height = 500
startx = (screen_width - window_width) // 2
starty = (screen_height - window_height) // 2
screen.setup(width=window_width, height=window_height, startx=startx, starty=starty)
screenTk = screen.getcanvas().winfo_toplevel()
screenTk.attributes("-fullscreen", True)
def exit_fullscreen():
    screenTk.attributes("-fullscreen", False)
    screen.setup(width=window_width, height=window_height, startx=startx, starty=starty)
screen.listen()
screen.onkey(exit_fullscreen, "Escape")
screenTk.protocol("WM_DELETE_WINDOW", on_close)
screen.onscreenclick(click)
circle()
turtle.mainloop()

this is my command prompt line if it also helps: python -m PyInstaller --onefile --add-data “C:\Users\Yarden\OneDrive\Documents\Python\randofolder\Recording.wav;Recording;Recording.wav” random2.py

I hate to sound like Stack Overflow, but isn’t this a duplicate of your other thread? I'm using the --windowed flag

Yes. My apologies. I hadn’t received any responses and remained with an unanswered question, so I thought I should make a new post.