blog.humaneguitarist.org

PowerShell hell and adding it to the context menu

[Sun, 08 Jan 2017 17:20:09 +0000]
I've recently been using Docker a little for work (or at least considering it) and PowerShell lets me do nested commands like $ docker rm $(docker ps -aq) which I can't do in the classic Windows Command Prompt. So, I've been trying to use PowerShell more than the classic Windows Command Prompt. Until now. Last night, I was doing something for work with Stanford's CoreNLP [http://stanfordnlp.github.io/CoreNLP/index.html], calling it from the command line via PowerShell. I noticed something didn't look like after I ran the command to get custom Named Entity Tags (NER) ... the Stanford output on the console looked a little wrong and the results weren't what I expected. Surely, I was doing something wrong. So I ran some older NER stuff to make sure at least the older tests I'd done were working. No. They weren't. And late on a Saturday night, I was getting a little annoyed. I decided to run the same command with the classic Windows Command Prompt - in order to try and recreate the scenario from the past when things were working. And guess what? The output looked fine and so did the final result. Could running the same command from PowerShell really alter the output? Apparently so. I got the proper results from the classic prompt as well as the Git Bash installed on my computer (which I used a lot because I can use Bash commands which I know better than PowerShell and DOS commands). I have no f-ing idea why the results are different with PowerShell, and I'm not sure I care. I'll just use the Git Bash for everything command line for now. Too bad I spent some time the other day adding a "PowerShell here" context menu option because I don't think I'll be using it much anymore. Here's the registry ".reg" file that I exported after getting the context menu option to work. Interestingly, the tutorials I saw online said to add the option at "HKEY_CLASSES_ROOT\Directory\shell\" in the registry. But I actually only got it work by adding it to "HKEY_CLASSES_ROOT\Directory\Background\shell\". Anyway, if you want to give it a try, save the following to a ".reg" file and clicking on it should update the registry. Do so at your own risk. Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Background\shell\powershell] @="PowerShell Here" [HKEY_CLASSES_ROOT\Directory\Background\shell\powershell\command] @="powershell.exe -noexit -command Set-Location '%V'"