我正尝试从C#应用程序重命名计算机名称。使用.NET重命名计算机名称
public class ComputerSystem : IComputerSystem
{
private readonly ManagementObject computerSystemObject;
public ComputerSystem()
{
var computerPath = string.Format("Win32_ComputerSystem.Name='{0}'", Environment.MachineName);
computerSystemObject = new ManagementObject(new ManagementPath(computerPath));
}
public bool Rename(string newComputerName)
{
var result = false;
var renameParameters = computerSystemObject.GetMethodParameters("Rename");
renameParameters["Name"] = newComputerName;
var output = computerSystemObject.InvokeMethod("Rename", renameParameters, null);
if (output != null)
{
var returnValue = (uint)Convert.ChangeType(output.Properties["ReturnValue"].Value, typeof(uint));
result = returnValue == 0;
}
return result;
}
}
的WMI调用返回错误代码1355
MSDN没有过多提及的错误代码,这是什么意思,我该如何解决?
是你特林在Active Directory环境中重新命名的电脑吗? –
这个*可能会对你有些兴趣:https://social.msdn.microsoft.com/Forums/vstudio/en-US/219c4b4b-b43a-4dbc-9e3c-a1135879c5f9/information-about-the-domain- could not-be-retrieve-1355?forum = netfxbcl –