Solved

How to convert batch input from qwertz to qwerty on x64?

Posted on 2014-03-24
11
369 Views
Last Modified: 2014-04-05
Hi experts!

If my batch goes
set /p Input=to be converted?
and the user enters "qwertz" on his qwertz (non-us) keyboard, I'd like to convert that variable "input" to qwerty before the batch continues to work with it.

How do I do this on windows 7/8/8.1 x64?
[also other characters should be converted, for example on a german keyboard, one enters "az?#" but the variable should be changed to "ay_\" ]
0
Comment
Question by:McKnife
  • 7
  • 4
11 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 39950995
Why should you want to do that? Isn't it much better to switch the keyboard setting to US in the batch file? That way the user sees the "wrong" input, and is forced to "correct" it immediately.
0
 
LVL 54

Author Comment

by:McKnife
ID: 39951005
Hi.

I would be perfectly ok with switching the layout to and fro.
How would you do that? On x86 systems, this ways possible using keyb.COM or KB16.COM, but those don't work on x64 system due to the fact that they are 16-bit-programs.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39951075
I see, that is correct. But why is the session's keyboard layout wrong? Are the users remoting into a RDP session on an US server, and are not able to switch to the correct culture / locale for their session?

Anyway, you can only replace one string by another one in cmd.exe batch files. Since you need to replace z with y and vice versa, that makes it very difficult (read impossible). To see the pain:
set /p Input=to be converted?
set Input=%Input:z=§%
set Input=%Input:y=z%
set Input=%Input:%§=y%

Open in new window

and that for replacint y <-> z only ...
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 54

Author Comment

by:McKnife
ID: 39951142
Yes, I know about character substitution.
Full story on "why?":
We are implementing Bitlocker and will use a batch where the users fill their password in.
It will be used as domain password and Bitlocker password. Problem is: Bitlocker's preboot authentication is set to en-us, while users have german keyboards. It is not switchable pre-boot.
MS knows about this problem and recommends to change the kb layout before setting/changing the BL password. This won't work here as the same input is used to change the domain password.

So we would have to do this in 2 separate steps, which is what we try to avoid by changing the layout inside the batch. Possible on x86, but not on x64.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39951377
The replacement algorithm is as shown above, and needs to be repeated for each pair to replace. And some characters need to be prefixed with a caret (%&!":|^=<> and some more).

VBS or PowerShell are better suited.
0
 
LVL 54

Author Comment

by:McKnife
ID: 39951406
I know that workaround. So you don't know a way to switch it and I guess you are tempted to say "there is no way"?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39951957
I beg your pardon? Do you mean "So you don't know a different way to switch it"? I told you some alternatives. And I don't know how to switch the input to a different keyboard from inside a batch without using keyb.
0
 
LVL 54

Author Comment

by:McKnife
ID: 39951974
No, don't get me wrong.
Your way is substitution. That way will work for the case that we have a known character set in use, but we haven't (sorry if the question title is misleading). Most are german keyboards, but not all. It will not work right away if some unknown keyboard layout comes along. So we would need to start reading out the current keyboard layout and then proceed depending on what we get which is possible, but wouldn't be my first choice for reasons that should be obvious.

In the meanwhile, I have found some clues (the command is "control intl.cpl,, /f xmlfile") and will see if those do the job.http://msdn.microsoft.com/en-ie/goglobal/bb964650%28en-us%29.aspx
0
 
LVL 54

Author Comment

by:McKnife
ID: 39956404
I am about to use powershell for this where we can use
Set-WinUserLanguageList -LanguageList en-us -force
Will see if that has it all.
0
 
LVL 54

Accepted Solution

by:
McKnife earned 0 total points
ID: 39967796
That does indeed solve it.
$OldList = Get-WinUserLanguageList
Set-WinUserLanguageList -LanguageList en-us –force
...some input action...
Set-WinUserLanguageList $OldList -force

Open in new window

0
 
LVL 54

Author Closing Comment

by:McKnife
ID: 39979853
No way was found in batch, so resorted to powershell.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question