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

标签 windows vbscript inno-setup administrator

我正在使用 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

谢谢@nlsbshtr

function GetNameBySID(const SID: string): string;
var
  WbemLocator, WbemServices, WbemService, WbemObjectSets: Variant;
begin;
  Result := '';
  WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  WbemServices := WbemLocator.ConnectServer('localhost', 'root\CIMV2');
  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;

关于windows - 如何获取不同语言的管理员组名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14499540/

相关文章:

vbscript - 测试完整工具和 VB 脚本教程

iis - 如何使用 cscript 和 vbs 参数从 Inno Setup 脚本调用 vbs 脚本?

inno-setup - 当未在 InputFilePage (CreateInputFilePage) 上选择文件时如何禁用 NextButton?

vbscript - 更改样式选择文件夹

windows - vbscript 输出到控制台

inno-setup - 如何从 Inno Setup 代码中删除文件夹(如果为空)?

C++ 半透明窗口 SDL

windows - 在 Windows XP 命令提示符下循环遍历目录

windows - 我的 groovy 库在哪里?

java - Inno 安装程序 : Extending Windows default apps list