加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 如何获取不同语言的管理员组名称

发布时间:2020-12-14 02:56:06 所属栏目:Windows 来源:网络整理
导读:我正在使用Inno Setup开发安装程序,我需要创建一个具有管理员权限的 Windows用户,我可以使用此命令正常运行:net localgroup administrators USER / add 但是有一个问题……如果我在非英语Windows上执行此操作,“管理员”,组将不存在,又名:如果在pt-br Wind
我正在使用Inno Setup开发安装程序,我需要创建一个具有管理员权限的 Windows用户,我可以使用此命令正常运行:net localgroup administrators USER / add

但是有一个问题……如果我在非英语Windows上执行此操作,“管理员”,组将不存在,又名:如果在pt-br Windows上安装它将被称为“Administradores”.

我想知道是否存在一个存储管理组名称的Windows变量.

请注意,使用Inno Setup我可以使用vbs脚本.

解决方法

我对Inno Setup也做了一个功能,我想这对Delphi也适用.

完整的SID列表:http://support.microsoft.com/kb/243330/en

Tks @nlsbshtr

function GetNameBySID(const SID: string): string;
var
  WbemLocator,WbemServices,WbemService,WbemObjectSets: Variant;
begin;
  Result := '';
  WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  WbemServices := WbemLocator.ConnectServer('localhost','rootCIMV2');
  WbemObjectSet := WbemServices.ExecQuery('SELECT Name FROM Win32_Group where SID="'+SID+'"');
  if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
  begin        
    WbemObject := WbemObjectSet.ItemIndex(0);
    if not VarIsNull(WbemObject) then
      Result := WbemObject.Name;      
  end;
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读