我有一个RDS系统,我正在尝试使用个人托管桌面来实现自动化。我想使用WMI自动执行更改,因为我无法从C#中正确执行powershell。
var objUser = new object();
var objDomain = new object();
var objCollection = new object();
Console.WriteLine("Enter domain\\User");
objUser = Console.ReadLine();
objDomain = "US";
Console.WriteLine("Enter Collection");
objCollection = Console.ReadLine();
var obj = new object[3]{ objCollection, objUser, objDomain};
try
{
var mgmt = new ManagementScope(@"root\cimv2\rdms");
var cls = new ManagementClass(mgmt.Path.Path, "Win32_RDMSVirtualDesktop",null);
var result = cls.InvokeMethod("GetVirtualDesktopAssignedToUser", obj);
Console.ReadKey();
}
catch (Exception e)
{
Console.WriteLine(e);
Console.ReadKey();
}
该代码将执行,结果将被赋值为4119。此link指出它确实返回了uint,但是如何访问输出字符串?