1

I have a ps1 file that is opened by default with Notepad. If I right click this file and choose Run with Powershell, the commands inside the file are correctly run.

But I would like Powershell to be the default program to run (not "open") this file. So, if I just right click the file, then open with, then choose default program and choose Windows Powershell, this is not enough, because the commands are not run. In this way, the file is just "opened", the Powershell windows opens and then disappears after a second.

How could I set Powershell to be the default program to RUN .ps1 files, or at least one particular .ps1 file?

1
  • 1
    I answered once this question here Commented Dec 26, 2013 at 20:33

1 Answer 1

1

Here are some registry bits to help out.

Double click - runs .ps1

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open]

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-file\" \"%1\""

Double Click 'Opens' via Notepad.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open]

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
@="\"C:\\Windows\\System32\\notepad.exe\" \"%1\""

This is assuming you are not using any powershell specific IDE (such as powerGUI or Sapien) which are known to alter the default .ps1 action and would require additional settings to make this work.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.