Den*_*nis 32
另一种解决方案是使用WMI.NET或Windows Management Instrumentation.
使用.NET Framework命名空间System.Management,您可以使用Windows Management Instrumentation(WMI)自动执行管理任务.
代码示例
using System.Management;
...
var processToRun = new[] { "notepad.exe" };
var connection = new ConnectionOptions();
connection.Username = "username";
connection.Password = "password";
var wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\cimv2", REMOTE_COMPUTER_NAME), connection);
var wmiProcess = new ManagementClass(wmiScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
wmiProcess.InvokeMethod("Create", processToRun);
Run Code Online (Sandbox Code Playgroud)
如果您在身份验证方面遇到问题,请检查DCOM配置.
dcomcnfg
从命令提示符运行. Component Services\Computers\My Computer\DCOM Config
8BC3F05E-D86B-11D0-A075-00C04FB68820
(您可以在详细信息视图中查看).注意:用于远程进程的所有路径都必须是目标计算机的本地路径.
归档时间: |
|
查看次数: |
117937 次 |
最近记录: |