You're right to be kidding me.@set AdminName=Administrators
@net user %AdminName% 2>&1
@IF ERRORLEVEL 1 set AdminName=Администраторы >nul
@echo %AdminName%
This code shall be placed in BAT-Fail (in 866 codes, otherwise the cables will be removed). Then use AdminName% for net.exe.More seriously like that (please include WMI, where we are without him, recalling that admins have always SID = 544@echo off
setlocal
set "wmic=wmic group where sid="S-1-5-32-544" get name /value"
for /f %%i in (' "%wmic%" ') do 1>nul set "%%i"
echo %name%
Likewise, use the percentages for your future purposes.Well, if it's Delphi, it's definitely WMI. I'm adding a universal code to call most WMI requests in Delphi:function GetWMIstring(wmiHost, root, wmiClass, wmiProperty: string): string;
var
objWMIService : OLEVariant;
colItems : OLEVariant;
colItem : OLEVariant;
oEnum : IEnumvariant;
iValue : LongWord;
function GetWMIObject(const objectName: String): IDispatch;
var
chEaten: Integer;
BindCtx: IBindCtx;
Moniker: IMoniker;
begin
OleCheck(CreateBindCtx(0, bindCtx));
OleCheck(MkParseDisplayName(BindCtx, StringToOleStr(objectName), chEaten, Moniker));
OleCheck(Moniker.BindToObject(BindCtx, nil, IDispatch, Result));
end;
begin
objWMIService := GetWMIObject(Format('winmgmts:\%s%s',[wmiHost,root]));
colItems := objWMIService.ExecQuery(Format('SELECT * FROM %s',[wmiClass]),'WQL',0);
oEnum := IUnknown(colItems.NewEnum) as IEnumVariant;
while oEnum.Next(1, colItem, iValue) = 0 do
begin
Result:=colItem.Properties.Item(wmiProperty, 0); //работает только с единичным откликом, если результат массив, надо добавлять работу с TStringList.
end;
end;
Use the function then: try
CoInitialize(nil);
try
AdminGroupName:=GetWMIstring('.', 'root\CIMV2', 'Win32_Group where SID="S-1-5-32-544"','Caption');
finally
CoUninitialize;
end;
except
on E:Exception do
begin
// обработка ошибок
end;
end;
And that's the name of the band in our pocket. It looks like you can add a user through Delphi but if you like net.exe, use it.