Solved Run PS1 files (double click) on Windows 11


ChristianL

Member
Local time
10:13 AM
Posts
2
OS
Windows 11 Education
Hello,
On Windows 10 I was able to modify the file association by using the following command :

Set-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command" -Name '(Default)' -Value '"C:\Program Files\PowerShell\7\pwsh.exe" -noLogo -ExecutionPolicy bypass -file "%1"'

This command no longer works on Windows 11 because the registry location does not exist. I need a way to make PS scripts to run with a double click and the solution must be in a form of a command , No GUI solutions please.

Thanks
 
Windows Build/Version
21H2

My Computer

System One

  • OS
    Windows 11 Education
    Computer type
    Laptop
    Manufacturer/Model
    Dell
    CPU
    Intel i9-10885H 2.4Ghz
    Motherboard
    Dell
    Memory
    32 GB
    Graphics Card(s)
    GTX 1650 TI
    Monitor(s) Displays
    2
    Screen Resolution
    3840x2400
    Hard Drives
    SSD - 1Tb
    Browser
    Edge
    Antivirus
    Sophos

abactuon

Active member
Member
Local time
10:13 PM
Posts
203
OS
Microsoft Windows 11 Home
Example. Running PS_ise.
Any .ps1 file -> Properties: Change PS_ise

# .ps1
If (!(Test-Path "HKCR:\PS_ise.ps1\DefaultIcon")) {
New-Item -Path "HKCR:\PS_ise.ps1\DefaultIcon" -Force
}
Set-ItemProperty -Path "HKCR:\PS_ise.ps1\DefaultIcon" -Name "(default)" -Type ExpandString -Value "$ExtLibraryIcons,-12" -Force
Set-ItemProperty -Path "HKCR:\.ps1" -Name "(default)" -Type String -Value "PS_ise.ps1" -Force
Set-ItemProperty -Path "HKCR:\PS_ise.ps1" -Name "(default)" -Type String -Value "File .ps1" -Force
If (!(Test-Path "HKCR:\PS_ise.ps1\Shell\Open\Command")) {
New-Item -Path "HKCR:\PS_ise.ps1\Shell\Open\Command" -Force
}
Set-ItemProperty -Path "HKCR:\PS_ise.ps1\Shell\Open" -Name "FriendlyAppName" -Type String -Value "PS_ise" -Force
Set-ItemProperty -Path "HKCR:\PS_ise.ps1\Shell\Open\Command" -Name "(default)" -Type String -Value '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe" "%1"'-Force
 

My Computer

System One

  • OS
    Microsoft Windows 11 Home
    Computer type
    Laptop
    Manufacturer/Model
    ASUS TUF Dash F15 FX516PM_FX516PM
    CPU
    Intel Core i7-11370H
    Motherboard
    ASUS FX516PM
    Memory
    Micron 4ATF1G64HZ-3G2E2/8G + Patriot PSD416G320081S
    Graphics Card(s)
    NVIDIA GeForce RTX 3060 Laptop
    Sound Card
    Intel Tiger Lake-U/Y PCH-LP - cAVS (Audio, Voice, Speech)
    Monitor(s) Displays
    LM156LF-2F03
    Screen Resolution
    1920 x 1080
    Hard Drives
    1. Noname 128GB SSD
    2. HFM512GD3JX013N
    PSU
    200W
    Mouse
    Corsair KATAR PRO XT
    Internet Speed
    70 Mbps
    Browser
    Firefox
    Antivirus
    Microsoft Defender Antivirus

ChristianL

Member
Thread Starter
Local time
10:13 AM
Posts
2
OS
Windows 11 Education
Thanks abactuon !! - I modified your script and everything is working as needed
 

My Computer

System One

  • OS
    Windows 11 Education
    Computer type
    Laptop
    Manufacturer/Model
    Dell
    CPU
    Intel i9-10885H 2.4Ghz
    Motherboard
    Dell
    Memory
    32 GB
    Graphics Card(s)
    GTX 1650 TI
    Monitor(s) Displays
    2
    Screen Resolution
    3840x2400
    Hard Drives
    SSD - 1Tb
    Browser
    Edge
    Antivirus
    Sophos
Top Bottom