Код:
@echo off
call:Rnd36Str 10 RND
call:SetParm sec.txt NewAdministratorName "%RND:~-15%"
call:OEM2UTF sec.txt
EXIT /b
:OEM2UTF %file%
::-------------
SETLOCAL& set $TMP=%TEMP%\%RANDOM%%RANDOM%.tmp
<nul >"%$TMP%" set /P $$=яю
cmd /u/c type "%~1" >>"%$TMP%"
copy "%$TMP%" "%~1">nul&& del "%$TMP%"
ENDLOCAL& EXIT /b
:SetParm %file% %parm% %val%
::--------------------------
SETLOCAL DisableDelayedExpansion
set $TMP=%TEMP%\%RANDOM%%RANDOM%.tmp
(for /f "tokens=* delims=01234567890" %%a in ('type "%~1"^|findstr /n "^"') do (
set "$a=%%a"& SETLOCAL EnableDelayedExpansion
for /f "tokens=1 delims== " %%b in ("!$a:~1!") do if /i "%%b"=="%~2" set "$a=:%~2 = %3"
echo(!$a:~1!
ENDLOCAL
))>"%$TMP%"
copy "%$TMP%" "%~1">nul&& del "%$TMP%"
ENDLOCAL& EXIT /b
:Rnd36Str %cnt% %var%
::-------------------
SETLOCAL EnableDelayedExpansion& set "str="
set "map=;0-0;1-1;2-2;3-3;4-4;5-5;6-6;7-7;8-8;9-9;10-a;11-b;12-c;13-d;14-e;15-f;16-g;17-h;18-i;19-j;20-k;21-l;22-m;23-n;24-o;25-p;26-q;27-r;28-s;29-t;30-u;31-v;32-w;33-x;34-y;35-z"
for /L %%L in (1,1,%~1) do (set /a dec=!RANDOM!
for /L %%N in (1,1,6) do if !dec! gtr 0 (
set /a "d=dec%%36,dec/=36"
call set h=%%map:*;!d!-=%%
set str=!h:~0,1!!str!
))
ENDLOCAL& set "%~2=%str%"& EXIT /b
P.S. кодировка самого батника WIN 1251