0
リモートシステム上のファイルをWMIとC#を使用してファイル名で検索するにはどうすればよいですか?C#でWMIを使用してファイル名でリモートシステム上のファイルを検索する方法は?
リモートシステム上のファイルをWMIとC#を使用してファイル名で検索するにはどうすればよいですか?C#でWMIを使用してファイル名でリモートシステム上のファイルを検索する方法は?
このコードを試してthisをチェックしてください。 WMIコードクリエーター(私の評判が<のためリンクできないため、googleをチェックしてください)は、簡単にWMIクエリーをテストできます。
using System;
using System.Management;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ConnectionOptions oConn = new ConnectionOptions();
oConn.Impersonation = ImpersonationLevel.Impersonate;
oConn.EnablePrivileges = true;
string[] arrComputers = "clientName"};
foreach (string strComputer in arrComputers)
{
Console.WriteLine("==========================================");
Console.WriteLine("Computer: " + strComputer);
Console.WriteLine("==========================================");
ManagementObjectSearcher searcher = new ManagementObjectSearcher
(
new ManagementScope("\\\\" + strComputer + "\\root\\CIMV2", oConn),
new ObjectQuery(@"SELECT * FROM CIM_DataFile WHERE Name = 'WhatyouWant.ToSearch'")
);
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("CIM_DataFile instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Path: {0}", queryObj["Path"]);
}
}
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);
}
}
}
}
ありがとうございました...! – rakzz
あなたにこれに関する詳細を教えてもらえますか? – jcolebrand
として、WMIを使用してリモートシステムでプロセスを開始および終了することができます。私は、ファイルとしてusngファイル名をキーワードとして検索することで、リモートシステムのファイルのパスを取得するために、このことをextndします... !! – rakzz