0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(Pythonの標準IDE)を右クリックメニューに追加したい

Posted at

PythonIDEを右クリックメニューから表示する

目的

Windowsで .py ファイルを右クリックしたときに「Edit with IDLE(Pythonの標準IDE)」をメニューに出したい。
でも環境によってはこれが表示されなかったり、別のエディタに関連付けを変えたときに消えたりする。
そこで、レジストリに直接「右クリックメニューを追加する設定」を書き込んで、PowerShellだけで復活させる。

下記のようなもの
スクリーンショット 2025-11-03 135309.png

# === 自分の環境の pythonw.exe に書き換える ===
$pythonw = "C:\Users\kenny\AppData\Local\Programs\Python\Python313\pythonw.exe"

# HKCR: をPowerShellで触れるようにする
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT -ErrorAction SilentlyContinue | Out-Null

# .py に対応するクラス Python.File にメニューを追加
$menuKey = "HKCR:\Python.File\shell\Edit with IDLE"
if (-not (Test-Path $menuKey)) {
    New-Item $menuKey -Force | Out-Null
}
Set-ItemProperty -Path $menuKey -Name "(default)" -Value "Edit with IDLE"

# 実際に起動するコマンドを登録
$cmdKey = Join-Path $menuKey "command"
if (-not (Test-Path $cmdKey)) {
    New-Item $cmdKey -Force | Out-Null
}
Set-ItemProperty -Path $cmdKey -Name "(default)" -Value "`"$pythonw`" -m idlelib `"%1`""

# Explorerを再起動して反映
Stop-Process -Name explorer -Force
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?