Skip to content Skip to sidebar Skip to footer

Why Is The Console Minimized Automatically?

I am a new to Python. Today I found a problem when running Python scripts in the console. When I run a script in cmd, it gets minimized automatically. Moreover, if I only open cmd

Solution 1:

It's misbehaving because opening .py files is currently handled by the Notepad++ text editor instead of either py.exe or python.exe. To fix this, begin by opening the Default Programs dialog in the Control Panel. Select the option to associate a file type or protocol with a program. Scroll to ".py" and double click on it. Select the "Python" entry with the Python logo on it, and preferably the one with a rocket on it if there's more than one. After clicking ok, the description should now be "Python File", and up at the top it should have the Python icon with "Python Software Foundation" beside it.

Confirm that the ProgId value in Explorer's UserChoice key for .py files has been changed to Python.File. For example:

>reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice /v ProgId

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice
    ProgId    REG_SZ    Python.File

Finally verify that the Python.File command template is what you expect it to be:

>reg query HKCR\Python.File\shell\open\command

HKEY_CLASSES_ROOT\Python.File\shell\open\command
    (Default)    REG_SZ    "C:\Windows\py.exe" "%L" %*

In my case, I have the py launcher installed for all users, which is the default setup for a Python 3 installation. "%L" or "%1" in the template is the fully-qualified path for the .py script, and %* is for the command-line parameters. If you have to fix this, it will be easiest to do it in regedit. Preferably you should edit the underlying software classes in either HKCU\Software\Classes or HKLM\Software\Classes instead of the combined HKCR view.


Post a Comment for "Why Is The Console Minimized Automatically?"