且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从远程计算机运行的Bat文件

更新时间:2022-12-24 19:58:27

ManagementPath myPath = new ManagementPath();
myPath.NamespacePath = @"root\CIMV2";
myPath.Server = MachineName; // Machine name is IP address of machine e.q. "192.168.0.222"

ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = UserName;
oConn.Password = Password;
oConn.EnablePrivileges = true;

ManagementScope scope = new ManagementScope(myPath, oConn);



确保您的UserName/Password帐户在远程计算机上具有管理特权.
如果您要在域的一部分机器上执行用户名,则您的用户名还必须具有域名,例如"administrator@mycomplay.local"或"administrator @ mycompanydomain".



Make sure your UserName/Password account has administrative privileges on remote machine.
Also your UserName needs to have domain name along with it like "administrator@mycomplay.local" or "administrator@mycompanydomain" if you are trying to execute it on a machine which is part of domain.