I am writing a code but it has not worked as expected. A simplified version of the code is as follows:
from subprocess import call
import time
call([r"C:\Windows\System32\notepad.exe"])
time.sleep(5)
call(["taskkill", "/im", "notepad.exe"])
When running the script above, the code does not run from the first line call
, that is, the script opens the notepad and waits for a response from call([r"C:\Windows\System32\notepad.exe"])
, but this only happens when I manually close the notepad.
I would like the script to open the notepad, wait 5 seconds and close it, without manual user intervention. So how can I do it?