is there any way to prevent the user from closing the cmd window of a python script on windows or maybe just disable the (X) close button ?? I have looked for answers already but i couldn't find anything that would help me
Asked
Active
Viewed 460 times
2
-
2It would be better to not open the window in the first place: https://stackoverflow.com/questions/9705982/pythonw-exe-or-python-exe – roganjosh Mar 13 '19 at 21:31
-
You need to take over the default control handlers. In VB you would write function and use `AddressOf` to pass it to Windows. https://learn.microsoft.com/en-us/windows/console/console-control-handlers – Noodles Mar 13 '19 at 21:32
-
unfortunately, I need to open the window – hazem gamal Mar 13 '19 at 21:34
-
1open a custom wx or QT console you're writing into, and disable the close gadget. – Jean-François Fabre Mar 13 '19 at 21:42
1 Answers
0
I dont think its possible, what you can do instead is to not display the cmd window (backgroundworker) and make it into a hidden process with system rights so that it cant be shutdown until it finishes.

shroud
- 1
- 1