使用 C# 远程更改 Windows Server 2008 计算机的计算机名称?
也许有人能够向我指出一个决定性的资源,以学习如何使用 C# 远程更改 Windows Server 2008 计算机上的计算机名称
我已经查看了很多网站寻求帮助,但现在在我的任务的第二天,实际上没有任何帮助更接近(除了决定 WMI 几乎是我唯一的选择)完全超出了我的正常技能,所以我想几乎任何信息都会很好,但尤其是与远程更改计算机名称有关的任何信息。 (这会在我从图像远程启动虚拟图像后立即发生......是的,我意识到需要重新启动)
谢谢
Might someone be able to point me towards a conclusive resource to learn how to remotely change a computer name on a Windows Server 2008 machine using C#
I've looked at lots of sites for help and now in day two of my task and not really any closer (other than deciding WMI is pretty much my only option) Totally out of my normal skillset so I guess pretty much any info would be nice, but especially anything having to do with changing a computer name remotely. (this would occur right after I remotely spin up a virutal from an image...and yes, i realize a reboot will be required)
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个很好的链接,它详细讨论了它,并且除了本地计算机名称之外还处理活动目录成员身份和计算机命名。
http://derricksweng.blogspot.com/2009/04/programmatically-renaming -computer.html
(顺便说一句,如果您必须处理 Active Directory 命名,我会考虑使用 ComputerPrincipal 类来自 System.DirectoryServices.AccountManagement 命名空间副博客文章中使用的 System.DirectoryServices 命名空间中的任何内容。)
调整了博客文章中的代码(您需要将对 System.Management 的引用添加到您的项目中):
Here is a nice link that discusses it in detail and also deals with active directory membership and machine naming in addition to the local machine name.
http://derricksweng.blogspot.com/2009/04/programmatically-renaming-computer.html
(Btw, should you have to deal with Active Directory naming, I would consider using the ComputerPrincipal class from the System.DirectoryServices.AccountManagement namespace vice anything from System.DirectoryServices namespace that was used in the blog post.)
Tweaked code from the blog post (you will need to add a reference to System.Management to your project):