我想使用 VBScript 和 WMI 获取本地计算机设置中用户权限分配的所有值。有没有办法使用 VBScript 和 WMI 来实现这一点?
谢谢。
答案1
下面是我在 C# .NET 中基于杰·亚当斯 链接和RSOP_UserPrivilegeRight 类文档,我想这很容易移植到 VBS:
using System.Management;
ManagementScope scope = new ManagementScope(@"\\localhost\root\rsop\computer");
ObjectQuery query = new ObjectQuery("SELECT * FROM RSOP_UserPrivilegeRight");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
scope.Connect();
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
Console.WriteLine("=> User right: {0}, precedence: {1}", m["UserRight"], m["precedence"]);
Action<string> action = new Action<string>(Console.WriteLine);
Array.ForEach((string[])m["AccountList"], action);
}