Tod*_*odd 1 .net c# windows-services
全部,
请原谅我对 C#/.NET 的无知,我对这两者(主要是 Java、C/C++)都完全陌生,并且发现自己的任务是创建一些代码,这些代码执行与可用的“wmic qfe”和“wmic os”命令相同的功能在 DOS 提示符下。
这能做到吗?如果是这样,任何帮助表示赞赏。我正在尝试通过 System.Management.Instrumentation 命名空间,因为 wmic 是 Windows Management Instrumentation Command 的首字母缩写词(根据 Google),但尚未发现任何有用的东西。
提前致谢,托德
小智 5
您可以简单地调用 wmic.exe,而不是使用 Management 类,它是一个 WMI 控制台,正如您可以从 exe 名称本身找出的那样。这是我使用通过 C#.net 调用的 WMIC 在远程计算机上打开记事本的代码。试试看。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace RemoteProcessDemo
{
class Program
{
static void Main(string[] args)
{
string strComputerName = "";
string strProcString = "";
try
{
strComputerName = args[0];
Process.Start("wmic", "/node:" + strComputerName + " process call create notepad.exe");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
问候, 图沙尔
| 归档时间: |
|
| 查看次数: |
9052 次 |
| 最近记录: |