Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-03-24
11
Medium Priority
?
399 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 71

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 56

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 71

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 56

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 71

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 56

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 71

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 56

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 56

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 56

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 56

Author Closing Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…

610 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