Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a cmd window using python 2.7

The title pretty much says it, although it does not need to be specific to a cmd, just closing an application in general. I have seen

os.system(taskkill blah blah)

this does not actually close the windows but rather just ends the cmd inside the window, I would like to actually close the window itself.

EDIT: Could someone please give me a specific line of code that would close a cmd window. The name of the cmd window when moused over is

C:\Windows\system32\cmd.exe
like image 635
Ulsting Avatar asked Feb 22 '26 19:02

Ulsting


1 Answers

something like this?

import sys
sys.exit()

or easier ...

raise SystemExit

if that's not what your looking for tell me

also you can just save the file with a .pyw and that doesn't open the cmd at all

like image 192
Serial Avatar answered Feb 24 '26 08:02

Serial