I tried searching for this, but only came across people who were missing quotations around their path, when they wanted to run a PowerShell .ps1 file. However, this is not my problem. I have the following folder structure:

C:\Users\user\Desktop\repositories\project folder\subfolder

As you can see, there is a folder called project folder. Because of that, when I double click a .ps1 file in Windows file explorer, it will open PowerShell but immediately close again. No output or anything.

I can only assume space in the path is the issue, that causes PowerShell to not find the file. When the file is directly moved into repositories folder, it works flawlessly.

Any clues how I can fix this? It's quite annoying that I have to:

SHIFT+RIGHT_CLICK the folder -> open PowerShell -> write the .ps1 name -> hit enter

1 Answer 1


Windows 10 64-bit. PowerShell 5.1

How to double click a powershell script with a space in the path.

Add -file to the registry, create a regfile, or download the regfile.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Applications\powershell.exe\shell\open\command] @="\"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\"
-file \"%1\""

Problem solved.

  • 2
    Though this works, this is not recommended. MS made .ps1 associated with a text editor (notepad) for a reason. Best practice, if you want to run .ps*, explicitly call PowerShell and the name of the script. Double click is just opening you up to unnecessary risks of random users, poping bad code.
    – postanote
    Jan 31, 2020 at 0:27
  • Sorry for the late reply. I forgot to reply to this, but I just wanted to say, that it works flawlessly. Thanks a lot Mar 2, 2020 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.