Solved

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

Posted on 2014-03-24
11
366 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…

808 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