Run Powershell PS1 From Shell

0 comments
I wanted to run Powershell scripts (PS1) files from the shell much like batch files. After searching the web I couldn't find any info on how to do this. Therefore I spent a few minutes and created a registry modification that adds an "Execute" option to the right click menu allowing one to run a PS1 file from the shell without having to create a shortcut.

I've only tested this on Windows XP. Modifying the registry can be dangerous and the following disclaimer applies: This posting is provided "AS IS" with no warranties, and confers no rights.

To install - save the following text to a .reg file on your computer and execute.

------------------------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1]
"EditFlags"=dword:00030000
"BrowserFlags"=dword:00000008
@=""

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\DefaultIcon]
@="C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe,0"

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell]
@="Execute"

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\Execute]

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\Execute\command]
@="C:\\WINDOWS\\system32\\windowspowershell\\v1.0\\powershell.exe -noexit &\"'%1'\""

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\Execute\ddeexec]

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\Execute\ddeexec\Application]
@="powershell"

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\Execute\ddeexec\Topic]
@="System"
------------------------