Run python script from command line not working

Slicer launcher (Slicer.exe) is built as a GUI application in the official Slicer installation packages. GUI applications are not killed if you hit Ctrl-C.

There is a trick that you can use if you really must use Ctrl-C instead of the X button. We include a console-mode launcher PythonSlicer.exe, you can rename that and replace the original GUI-mode Slicer.exe launcher. The console-mode launcher will respond to Ctrl-C on the latest Slicer Preview Release (because there the SlicerApp-real.exe executable is also built as a console application). However killing the process like this will not result in a clean exit, because objects are not destructed so VTK will report memory leaks. Stable releases might be built with error leak reporting disabled, but that will not stop on Ctrl-C (because in that version SlicerApp-real.exe is not a console application yet). If you want a solution for a clean exit from the command prompt using Ctrl-C then you need to build Slicer yourself or wait for the new Slicer Stable Release (expected in a week or so).

What is your overall goal? How would you like to launch and stop Slicer?