How to detect the MSDOS language?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
budhax
Posts: 63
Joined: 09 Oct 2006 12:25

How to detect the MSDOS language?

#1 Post by budhax » 22 May 2012 13:24

Hello,

I wrote this script to take ownership recursively of the folder dropped on the script.
http://www.tipandtrick.net/2008/how-to- ... -in-vista/

Code: Select all

takeown /f "%~1" /r /d y
icacls "%~1" /grant administrators:f /t


The command on the 1st line (takeown) doesn't work if I use this script on a French Windows.
Because the parameter "y" (for YES) is not accepted for French Windows.
For French Windows I have to use "o" (for OUI in French).
Ridiculous.

1. Why for this command, the parameter depends of the MSDOS language?
2. Is the a way (MS DOS script) to take ownership, independently of the MSDOS language?
3. How to get the MS DOS language?


Thanks and regards.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: How to detect the MSDOS language?

#2 Post by Ed Dyreen » 22 May 2012 14:53

'
On XP you can use the value of "HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language",InstallLanguage.
You could map this table

Code: Select all

set "%%~?.0405=cz" &set "%%~?.0414=no" &set "%%~?.080C=be"
set "%%~?.0406=dk" &set "%%~?.0415=pl" &set "%%~?.0813=be"
set "%%~?.0407=gr" &set "%%~?.0416=br" &set "%%~?.0816=po"
set "%%~?.0409=us" &set "%%~?.0419=ru" &set "%%~?.0C0C=cf"
set "%%~?.040A=sp" &set "%%~?.041A=yu" &set "%%~?.1009=us"
set "%%~?.040B=su" &set "%%~?.041B=sl" &set "%%~?.100C=sf"
set "%%~?.040C=fr" &set "%%~?.041D=sv" &set "%%~?.0409=dv"
set "%%~?.040E=hu" &set "%%~?.0807=sg" &set "%%~?.040A=sp"
set "%%~?.040F=us" &set "%%~?.0809=uk" &set "%%~?.0C0C=cf"
set "%%~?.0410=it" &set "%%~?.080A=la" &set "%%~?.0409=us"
set "%%~?.0413=nl"
set "%%~?."
something like

Code: Select all

( %Lang_% $region, 1 ) &if /i "!$region!" == "fr" (
   echo.fr
) else if /i "!$region!" == "us" (
   echo.us
)

budhax
Posts: 63
Joined: 09 Oct 2006 12:25

Re: How to detect the MSDOS language?

#3 Post by budhax » 23 May 2012 06:17

Thank you Ed Dyreen.

Another solution by IA-32:
http://ss64.org/viewtopic.php?pid=5713#p5713

Code: Select all

takeown /f "%~1" /r /d y 2>nul
if errorlevel 1 takeown /f "%~1" /r /d o
icacls "%~1" /grant administrators:f /t

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to detect the MSDOS language?

#4 Post by foxidrive » 23 May 2012 19:40

budhax wrote:Thank you Ed Dyreen.

Another solution by IA-32:
http://ss64.org/viewtopic.php?pid=5713#p5713

Code: Select all

takeown /f "%~1" /r /d y 2>nul
if errorlevel 1 takeown /f "%~1" /r /d o
icacls "%~1" /grant administrators:f /t


That can run takeown again from a false positive, when takeown encounters an error.

A better way is to read STDERR and only run it a second time if the error message shows that it is that o/y error.

Post Reply