Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like, by default, for PowerShell to be launched instead of Command when, say, running a batch file, or when I "Open Command Window Here", etc.

Any suggestions?

share|improve this question
I don't think powershell can interpret batch files, so you probably shouldn't make it open those. – nhinkle May 28 '11 at 2:52

I just did a very quick test and the following registry entry will add a "PowerShell here" item to the context menu of all folders in explorer:

Windows Registry Editor Version 5.00

@="&PowerShell here"

@="cmd.exe /c start \"PS\" powershell.exe -NoExit -Command \"cd \\\"%1\\\"\""

Just import it into the registry. I am using cmd.exe to bootstrap powershell in order to avoid having to hard-code the path.

Regarding cmd scripts/batch files. I think it does not make much sense to run CMD scripts within PowerShell by default. But it might be possible as well by modifying HKCR\cmdfile\shell\open registry key

share|improve this answer
Thanks! I'll give these a try tonight. The only reason I want scripts to open in powershell is for consistency and cooperation with my windowing tools. You are right that there is no inherent practical reason. ;) – Ipsquiggle May 28 '11 at 0:30

You're not going to get very far with running CMD batch files in PowerShell.

You can try changing the %COMSPEC% variable to point at powershell.exe using setx, but I don't think it will take you long to realise that this is a really bad idea and change it back again.

save the file as *.ps1 instead of *.bat and it will use powershell

share|improve this answer
Why is it a bad idea? Just curious. – afrazier Jun 14 '11 at 16:31
@afrazier: I have not experimented with changing %COMSPEC% to a non-CMD-compatible shell, but I assume that changing it to PowerShell would result in .cmd/.bat files trying to execute in PowerShell, so they would fail. I have installed a lot of software which needed to use batch files, so doing that would be a bad idea. Also, I am a bit biased, as I use CMD all the time (actually, TCC, which is an expanded superset), for everyday file managing - I only use PowerShell for system stuff, although I have a lot more to learn, as it is so powerful in comparison. – paradroid Jun 14 '11 at 18:26
Just for giggles, I've changed %ComSpec% to point to PowerShell on my Win7 system. The first couple .cmd files I tested work just fine. They involve cmd-specific constructs (for, Variable manipulation, if), so PS is apparently smart enough to know when it needs to invoke cmd.exe. – afrazier Jun 14 '11 at 18:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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