question

LapoFalcone-0416 avatar image
0 Votes"
LapoFalcone-0416 asked Miles-MSFT edited

VirtualTerminalLevel registry is not present

Hello,
I'm facing an issue about color codes in cmd (and PowerShell). Basically they haven't been working since 2016.
On the other hand I need a way to color text on terminal for a work project, and, looking for a solution, I discovered these possible fixes: https://github.com/microsoft/WSL/issues/1173 and https://github.com/quarkusio/quarkus/issues/1029

The solution (a pretty hacky solution, but I need this to work on a handful of computers, so no problem), is to edit the HKEY_CURRENT_USER/Console/VirtualTerminalLevel registry to 1 hex. But I don't have that registry! Initially I looked for it on the regedit.exe utility, and then I tried the REG QUERY HKEY_CURRENT_USER/Console command, but the registry simply isn't there.

I tried to add that registry via REG ADD (...) but of course it doesn't work.

So what can I do to make ANSI escape codes work? The program I'm working on is in Java, and I cannot use JNA or JNI. Is there a solution?

I'm on Windows 20H0 19042.985

If you need more info I'll provide them as soon as possible.

Thanks in advance, Lapo

windows-10-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Miles-MSFT avatar image
0 Votes"
Miles-MSFT answered Miles-MSFT edited

Hi
To add the registry , we could follow these steps:
102019-1.jpg

101939-2.jpg

Best Regards


1.jpg (26.9 KiB)
2.jpg (22.0 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello, sorry for the late reply but I had trouble logging in during last days.
Thanks for the answer, but by reading the images you attached I don't understand what you did. I see that in the first image it doesn't work and in the second image it prints blue text, but I don't understand what you did to make it work. Can you please elaborate a bit more?

Thanks again for the answer! Lapo

0 Votes 0 ·

Hi
After we studying your problem ,we found that when we use this command $esc=$([char]27);write-output "$esc[0;91mABC$esc[0m" in powershell , we could change the text color.

If we want to change the colour , we could chnage the number of this command ,such as 91>31

$esc=$([char]27);write-output "$esc[0;91mABC$esc[0m" > $esc=$([char]27);write-output "$esc[0;31mABC$esc[0m"

My testing computer also does not have the register.

About more specific information ,please refer to this link which may be helpful to solve your problem.


https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

Best Regards

--please don't forget to Accept as answer if the reply is helpful--









0 Votes 0 ·