2D, 3D, game, games, online game, game development, game engine, programming, OpenGL, Open AI, math, graphics, design, graphic, graphics, game development, game engine, programming, web development, web art, web graphic, arts, tutorial, tutorials,
miercuri, 1 iulie 2026
Tools : use powershell scripting to fix python bad run windows store .
Use this powershell source code will fix the python command when start the windows store.
# Run first
# Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# --- Create Form ---
$form = New-Object System.Windows.Forms.Form
$form.Text = "Python Path Fixer"
$form.Size = New-Object System.Drawing.Size(500, 300)
$form.StartPosition = 'CenterScreen'
# --- Label & Path Input ---
$label = New-Object System.Windows.Forms.Label
$label.Text = "Python Directory:"
$label.Location = New-Object System.Drawing.Point(10, 20)
$label.AutoSize = $true
$form.Controls.Add($label)
$txtPath = New-Object System.Windows.Forms.TextBox
$txtPath.Location = New-Object System.Drawing.Point(10, 45)
$txtPath.Size = New-Object System.Drawing.Size(460, 20)
$txtPath.Text = "C:\PythonInstall"
$form.Controls.Add($txtPath)
# --- Log Box ---
$txtLog = New-Object System.Windows.Forms.TextBox
$txtLog.Multiline = $true
$txtLog.ScrollBars = 'Vertical'
$txtLog.Location = New-Object System.Drawing.Point(10, 80)
$txtLog.Size = New-Object System.Drawing.Size(460, 130)
$txtLog.ReadOnly = $true
$form.Controls.Add($txtLog)
# --- Fix Button ---
$btnFix = New-Object System.Windows.Forms.Button
$btnFix.Text = "Check and Fix Path"
$btnFix.Location = New-Object System.Drawing.Point(10, 220)
$btnFix.Size = New-Object System.Drawing.Size(460, 30)
$btnFix.Add_Click({
$pythonFolder = $txtPath.Text
$pythonExe = Join-Path $pythonFolder "python.exe"
$txtLog.Text = "Checking: $pythonExe`r`n"
if (Test-Path $pythonExe) {
$txtLog.AppendText("[+] Python found. Updating PATH...`r`n")
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$pathParts = $currentPath -split ";" | Where-Object { $_ -ne $pythonFolder -and $_ -ne "" }
$newPath = "$pythonFolder;" + ($pathParts -join ";")
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
$txtLog.AppendText("[OK] Priority set successfully!`r`nPlease restart your terminal.")
} else {
$txtLog.AppendText("[ERROR] python.exe not found in the specified directory!")
}
})
$form.Controls.Add($btnFix)
[void]$form.ShowDialog()
Posted by
Cătălin George Feștilă
Labels:
2026,
powershell,
programming,
python,
python3,
script,
tool,
tools,
windows 10
Abonați-vă la:
Postări (Atom)