Solved

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

Posted on 2014-03-24
11
362 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 68

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 53

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 68

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
 
LVL 53

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 68

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 53

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 68

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 53

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 53

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 53

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 53

Author Closing Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article covers how to install the Microsoft Windows Operating System (OS). What is covered in this article:  > Different Versions and Editions of the Windows OS  > Upgrading versus Fresh Installation of the OS           - Steps to take pr…
This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now