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?
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?
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
[HKEY_CLASSES_ROOT\Directory\shell\PowerShellHere]
@="&PowerShell here"
[HKEY_CLASSES_ROOT\Directory\shell\PowerShellHere\command]
@="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
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
%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.
%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.
%ComSpec% to powershell breaks the mercurial version control commands.