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.
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
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).
Related
On windows 7, I would like to change the system locale from the command line without restarting. Is there any windows command line utility or the one in cygwin that I can use?
Thanks
The following link has information of how to change system locale kind of information from the command-line using the intlcfg.exe command.
An example command for you could be as follows, which would change syslocale to US-english en-US.
intlcfg.exe –syslocale:en-US
NOTE: You may still need to reboot for the settings to take effect, have not tried this so unsure about this part.
Doing a quick Google search turned up a lot of results with different ways to do it.
This TechNet article details how to use the Intlcfg command to change settings such as the Locale
Update language and locale settings
intlcfg.exe [-all:language_name] [-uilang:language_name] [uilangfallback:language_name] [-syslocale:language_name][-userlocale:language_name] [-inputlocale:default_keyboard_description; keyboard_description or locale_name] [-userhive:registry_path] [-syshive:registry_path] [-swhive:registry_path] [-image:path] [-dist:path] [-silent] [-skudefaults:language]
This article on AutoIt.com talks about setting up XML files and creating a script to switch between them.
It's hard to quote, but the gist is:
Create a text file with the settings
Use rundll32 to apply the changes to the registry
I need to know if a program exists ( or if I can create) that runs that computer's command prompt from a USB, without having to log in. I guess I don't really care if it is that computers cmd, but I need all of the modern functions of today's cmd. I also need to make sure that it has full administrative privileges. I know that it is possible, because just about every Linux system uses a similar system when it initially boots up, even when just downloaded to USB.
I guess I really need something that I can use with multiboot (a pure ISO file, not something like Rufus, which requires you to format usb). I don't know, but I don't think an ms dos thingy would have all of today's commands in cmd.
Any help much appreciated. Piece.
Edit: I just need the equvolent of single user mode in a Mac. Administrative access to the terminal without login info.
You can boot windows to safe mode limited command prompt, or you can launch a cmd window via the startup group (but you can't get a full screen after XP and the window can be closed with the latter method).
That is the first issue for you to solve, and then you can consider booting from USB.
I have my own installer program which I use to install several applications I have written.
I have been updating this program to avoid the application's data file updates going to the user's VirtualStore, as I read this was a "bad thing". I am doing this by storing the program and common data files separately in their correct locations, instead of sticking everything in Program Files like we used to do in the days of XP.
I am also now using SHGetFolderPath (yes, it's deprecated, but I still need to support my XP users), to get known folders instead of trawling the registry, which is another "bad thing" (I read).
The next thing I was trying to do was rewrite the installer code to avoid registry redirection to Wow6432Node when writing stuff to HKLM, as I thought this was another "bad thing".
However, although I could put the application specific stuff that goes there (like the install folder, if the user decides to install in other than the default), the killer is the need to put the uninstall info in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall. For 32-bit stuff running on a 64-bit system, this is redirected to Wow6432Node. I don't see any way round this - is it in fact possible?
UAC registry redirection could reasonably be described as a "bad thing" because it is designed specifically to provide compatibility with improperly written software, i.e., software that assumes it is going to be run with administrator privilege.
WOW64 registry redirection is a different beast; it's designed to provide compatibility with properly written 32-bit software. If your software is 32-bit, and has no specific need to be 64-bit aware, there's nothing wrong with letting it run in the emulation environment as-is, including allowing registry settings to be redirected to Wow6432Node.
You can bypass WOW64 registry redirection if necessary, but you shouldn't do this arbitrarily, only if there is a specific reason. If WOW64 redirection worries you, the only good alternative is to provide a 64-bit version of your program.
This is a very "BAD THING" !
Microsoft solves a security problem by hiding thing at another place !
I've created a programm to ask the user for some additional parameters (language, directory for lessons) during installation of the app. I tested the programm profoundly, and the registry entries were made perfectly. However during setup the entries were hidden at some strange place!
If Microsoft wants to redirect these enties it should at least be some option to be set.
Never hide things, and think they will not notice, because it's transparant.
Doing this properly would involve an option to be set, so users are aware of the redirection !
I want to be able to detect whether a given exe was shellex'd programmatically or if it was entered and executed interactively in, say, CMD.EXE.
Is there anything about the way an exe is launched that indicates the mechanism that was used to launch it?
Context: Windows XP, Visual Studio 6 languages.
There might be an easier way, but the only way I can think of is to check the parent process name, which involves a few steps:
Get the ID of the parent process.
Get the handle of the process, using the ID.
Use GetModuleFileNameEx with the handle found (and NULL as the module) to get the executable's name.
Check if the executable's name is cmd.exe or whatever.
Bear in mind that the parent process might already be gone when (or while) you do this check.
Edit:
If your program is a console application, you can also check the console it's running in. If it was run from cmd, it will usually use the same console. So, you can use GetConsoleTitle, for instance, and see if it's "Command Prompt". This might not work on localized or different versions of Windows, but it's easy if you have limitated cases. You can also use GetConsoleWindow and GetWindowThreadProcessId instead of steps 1 and 2.
You can differ between say CMD and Explorer by inspecting the parent process, but you can't tell if it happened due to user action or not. Also AFAIK all ways to launch a process result in the same NtCreateProcess/PspCreateProcess call, so you can't tell which API was used either.
Would there be a way to search an entire domain for a specific file through the command prompt.
I am using dir/s Example.txt but of course that only searches one specific computer.
You could get a list of computer objects from the domain using an LDAP query in a VBScript, then iterate through the list of computers using a For Each and then execute the dir /s command on each of the computers in turn and read the output from the command and parse your results to see if you get a hit.
It wouldn't be pretty but it'd work.
EDIT
It'd use the credentials of whatever was running the executable at the time. Using WinNT is ok, but if you want to do it properly, use the DirectoryServices (I know it's C#, but you get the drift from there and can use this to convert) namespace.
Once you have your list of computers, you need to iterate through them and run your command/process against each computer.
One easy way would be to get a computer list, and then access them using the UNC path and the administrative shares ([driveletter]$). You would have to do this from an account with administrative access on all of the computers.
\\computer01\c$\windows
That would give you the windows folder on computer01. Throw that in a for-each loop, and do the searching as normal.
Also depending on the number of computers you are looking at, and the network conditions, you might be able to speed things up if you spawned a few worker threads.