Latest posts by Timothy Warner (see all)
- SolarWinds Access Rights Auditor: Free Active Directory and file server risk assessment - Tue, Jul 9 2019
- Join a Debian Linux server to an Active Directory domain - Mon, Jul 1 2019
- Use Windows Admin Center with PowerShell - Wed, Jun 26 2019
If you’ve spent any appreciable amount of time working at the Windows command prompt, you definitely understand its weak points. For instance, have you ever tried to copy console output to the clipboard and paste it into a document file? Good luck with that.
In case you ever wondered, Conhost.exe is truly the “heart” of the Windows command prompt. Actually, I don’t use the 64-bit command processor, Cmd.exe, very much. Instead, I have a PowerShell.exe console session always running on my client and server systems.
As you can see in the following Process Explorer screenshot, both Cmd.exe and PowerShell.exe are hosted by the Conhost.exe executable. What this means for us is that all of the console customization options, including the new “experimental” Windows 10 features, apply to both Cmd.exe and PowerShell.exe. In fact, in my examples today, I’ll use PowerShell because, after all, we should now be using PowerShell exclusively, right? 😉
Process Explorer reveals that Cmd.exe and PowerShell.exe are both hosted by Conhost.exe.
By the way, I used Windows 10 Technical Preview build 9879 when I wrote this article. You can actually update your current Windows 10 installation to the latest build directly within the OS; navigate to PC Settings > Update and Recovery > Preview Builds and follow the instructions.
Unlocking the new command prompt features ^
Depending on your Windows 10 build version, the “experimental” console features may be all enabled or all disabled. Fire up an elevated Windows PowerShell console session, open the control menu from the upper-left corner of the window, and select Properties. On the Properties dialog, navigate to the Experimental tab. You’ll see the interface given in the following screenshot:
The experimental console features may be enabled by default, depending on which Windows 10 Technical Preview build you have.
Note that you can globally enable or disable all experimental features, or you can selectively enable only those that you’re interested in. I’m going to walk you through each of these options right now and give you practical examples of how each option works.
Incidentally, hovering your mouse over each experimental feature produces a helpful tooltip that summarizes its action.
We use the Opacity slider control to adjust console window transparency. This is a bigger deal than you might think. Imagine that you wanted to overlay your PowerShell console window on a web page that’s teaching you some new PowerShell code. If you don’t have a multi-monitor setup, you likely jog windows back and forth, back and forth.
To illustrate the usefulness of opacity, check out the following screenshot that demonstrates what I’m talking about:
The opacity feature makes it much easier to transfer code from a background window.
In case you wondered, the reason the lowest opacity setting is 40 percent is because (and I’m attempting to read the minds of the Microsoft developers here) it would make no sense to have a completely transparent console window.
Enable line wrapping selection ^
In Windows 8.1 and earlier versions, the Mark functionality is…lacking. You use your mouse to draw a rectangle selection area over the console output you want to copy, but there’s no line wrapping. Therefore, pasting that copied data from the console window normally requires that you “massage” the pasted output to make it look acceptable.
In Windows 10 Technical Preview, the selection rectangle wraps lines properly, as shown in the next screenshot:
Windows 10 finally gives us line wrapping for marked selections.
If you don’t know what I’m talking about when I say “mark,” here’s the deal: on the console properties window, you should have Quick Edit enabled. This allows you to open the control box, click Edit > Mark, and then use the mouse to select console output. Next, in your target application, you can press CTRL+V to paste the output.
Filter clipboard contents on paste ^
It drives me nuts when I select text that contains “smart” or “curly” quotes in an application, and then my PowerShell code breaks because the shell doesn’t understand my use of non-straight quotes. Remember that curly quotes and straight quotes are totally separate character codes!
Another problem occurs when your source text contains tabs. Again, your interpreter may bark at you because it doesn’t expect a tab character.
Windows 10 will automagically convert smart quotes to straight quotes and will remove errant tab spaces, as shown in the following screenshot:
Windows 10 handles common encoding problems by converting smart quotes and removing tabs.
Wrap text output on resize ^
Have you heard the term “the responsive web”? It’s a buzzword nowadays that means, in part, that web page content should dynamically resize depending on the user’s hardware platform, browser version, and even window size.
This Windows 10 experimental feature does the same thing—it automatically reflows the console output depending on the size of the console window. I show you this in the following screenshot:
The responsive web comes to the Windows command prompt!
Enable new CTRL key shortcuts ^
In Windows 8.1 and earlier, you’ll have a difficult time using everyone’s favorite copy and paste shortcuts. Specifically, CTRL+C will perform a BREAK instead of a copy, and CTRL+V displays a caret V on screen. Not too helpful. I show you this in the following screenshot, by the way:
When I pressed CTRL+C on my Windows 8.1 box, the command execution broke. When I pressed CTRL+V, my clipboard contents were not pasted to the console. A sad day, indeed.
Check this out: in Windows 10 Technical Preview, you can use CTRL+C both to copy and to break output. If you have select in the console window selected, then CTRL+C copies; otherwise, a BREAK is issued.
In contrast, CTRL+V finally performs a paste in the Windows 10 console host! Yes!
Extended edit keys ^
Frankly, Microsoft hasn’t been forthcoming as to exactly what these “extended edit keys” are. However, I did perform some testing. Here are a bunch of editing keyboard shortcuts that do work in Windows 10 Technical Preview:
- CTRL+F: Find
- CTRL+UP ARROW: Scroll up by line
- CTRL+DOWN ARROW: Scroll down by line
- CTRL+PGUP: Scroll up by screen
- CTRL+PGDOWN: Scroll down by screen
- ALT+ENTER: Toggle full-screen view
- CTRL+M: Mark
- CTRL+C: Break, Copy
- CTRL+V: Paste
Trim leading zeros on selection ^
The Windows 10 console host allows us to double-click numbers or strings to perform a quick mark (copy). What’s neat is that, by default (as long as you have the experimental feature enabled), the command prompt will trim leading zeros from numeric data, starting with the first significant digit.
The Windows 10 console is “smart” enough NOT to trim leading zeros when you use special number formats such as hexadecimal—the values for which normally start with the prefix 0x. You can see this behavior in the following screenshot:
Windows 10 trims leading zeros unless you’re using a special number type such as hexadecimal.
What do you say about the revised command prompt? Which new features do you like? What could Microsoft do better?