I have run a console application,and i want it to directly close the entire cmd prompt window when the user enters 'exit' ive tried using exit(0) and sys.exit() but they just close the script only and not the actually cmd.prompt window.
1 Answer
It's not the cleanest approach but the only way I could think of is this:
import os
os.system('title kill_window')
os.system(f'taskkill /f /fi "WINDOWTITLE eq kill_window"')
Basically, this sets the title of the cmd window to something unique (eg. kill_window), and then uses the taskkill command to search through and kill any processes with that name.
`
brackets for paths and code fragments. To highlight apps' names or interface, use a bold (**
brackets) or italic (*
brackets) font.