Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make system calls (Windows Command Prompt) answer in english

I'm working on a Perl script that needs to do a few system calls to obtain some system data. In order to parse the output of those calls reliably on any computer, I need to be sure the output of the call is set to English.

The problem I'm facing is that, for example in my PC, I get localized output from those commands. My Windows is setup in Spanish so, calls like systeminfo return data in Spanish.

Is there a command (or something else) I can run in a command call to make all system calls act like if the system was in English always, without having to modify anything in the system configuration?

Thanks in advance for your comments.

NOTES for bounty: The answer to this problem must not interfere with the system in any way. It should be a way to obtain english answers from system calls/commands that works in any machine without modifying its configuration, registry or else.

like image 766
Francisco Zarabozo Avatar asked May 15 '13 11:05

Francisco Zarabozo


2 Answers

This solution allows you to make Command Prompt act in english. It does alter some registry keys but it also changes them back if you want. You can run the same commands that they put in the .bats to make the system go to english and them go back to localized.

If you're trying to run commands that require adminsitrator privileges, then you can include these calls in your program without problems.

HTH

like image 60
Max Power Avatar answered Oct 14 '22 03:10

Max Power


I think the WMIC command is your best best. It has been a standard feature of Windows since Windows XP.

WMIC has full access to the Windows system (subject to user permissions, etc.), and has a locale option that selects the locale in effect (for the command) from the installed language packs.

The locale is selected from the list here.

To get the current username using US English (if it's available) you'd use wmic /locale:ms_409 netlogin get name

Through the WMI interface, you may not even need to localise the results (i.e.: with sufficient care, you may just get the raw data).

like image 43
Richard Avatar answered Oct 14 '22 05:10

Richard