Page 1 of 1

How to detect the MSDOS language?

Posted: 22 May 2012 13:24
by budhax
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.

Re: How to detect the MSDOS language?

Posted: 22 May 2012 14:53
by Ed Dyreen
'
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
)

Re: How to detect the MSDOS language?

Posted: 23 May 2012 06:17
by budhax
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

Re: How to detect the MSDOS language?

Posted: 23 May 2012 19:40
by foxidrive
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.