Thursday, February 6, 2014

TextPad Tip O-The Day: Adding a PowerShell Tool Link

I loves me some TextPad!  I'm fully aware that code editors are near to religion in terms of sincerity and defensiveness on the part of programmers (those of whom that are of spiritual or religious leaning, that is).  Maybe it would be better to compare/relate it to caffeine sources?  Anyhow, onward...

One of the many nice aspects of TextPad 7 is the extensible "Tools" feature.  This is where you can add links to invoke external tools to execute your code.  So if you like working with VBScript, you can create a Tool that points to %windir%\System32\cscript.exe.  If you like KiXtart, you can point it to wherever Kix32.exe resides (the one biggest and coolest feature of age-old Kix is that it is one of the few *truly* portable script engines alive today).  But, what about PowerShell?

On a typical Windows 8 or 8.1 computer, there may be two (2) distinct PowerShell environments you can use: 32-bit and 64-bit.  They are separate and live in separate houses with their own separate dinner times and kitchens.  You heard right.  One of my frustrations is that I have to configure "Set-ExecutionPolicy" for each of two separately in order to invoke them as I wish.  In my case, I set them both to Unrestricted.  I live on the edge.


My favorite part is the wonderfully-formatted warning message you see when setting the execution policy to Unrestricted...


(Word-wrap wasn't yet invented I suppose.)

Anyhow, to set up a new "Tool" for each PowerShell executable, do the following:

  1. Select the "Configure" menu option, and click "Preferences"
  2. Scroll down and expand "Tools"
  3. Click the 'Add" button, and select "Program..."
  4. In the "Command" box, past in the path to whichever PowerShell.exe you wish to map (I provide the paths for each below.
  5. Click OK
You may want to rename the Tool after saving it (it doesn't offer the option to name it, oddly).  To do so, click directly on the "Tools" link, so the individual tools are shown in the middle selection box. Click on a Tool to rename it (e.g. "PowerShell 32" or "PowerShell 64", and so on).

You can edit the Tool preferences afterwards as well. So you can check options for "Prompt for parameters" and "Suppress output until completed", and so on.  The defaults usually work well enough for most nerds (like myself).


Paths:
32-bit - %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe
64-bit - %WINDIR%\SysWow64\WindowsPowerShell\v1.0\powershell.exe

(note that the ISE flavors for each are in these same respective folder locations).

Disclaimer: I receive no compensation from Helios (makers of TextPad) whatsoever.  I just enjoy using their flagship product for all the wacky coding I do, from HTML to LISP to PHP, to ASP and VBScript, to Javascript, XHTML T-SQL, Batch, and now PowerShell.

You can download the trialware from http://www.textpad.com and a license is only $27 (USD).  A bargain.
Post a Comment