Solved

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

Posted on 2014-03-24
11
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 70

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 70

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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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 70

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 70

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

The way I use Experts Exchange to assist me in analyzing and diagnosing a problem is I first enter a Verbose Question at Experts Exchange like: Office 2007 will hang when opening and saving files I then launch WordPad (any text editor will do) an…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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). …

739 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