WMI を使用してアプリケーションをリモートでアンインストールするミニ w32 実行可能ファイルを作成しようとしています。
以下のコードを使用して、インストールされているすべてのアプリケーションを一覧表示できますが、WMI と C# を使用してアプリケーションをリモートでアンインストールする方法が見つかりませんでした。
プロセスとして msiexec を使用して同じことができることはわかっていますが、可能であれば WMI を使用してこれを解決したいと考えています...
ありがとう、セム
static void RemoteUninstall(string appname)
{
ConnectionOptions options = new ConnectionOptions();
options.Username = "administrator";
options.Password = "xxx";
ManagementScope scope = new ManagementScope("\\\\192.168.10.111\\root\\cimv2", options);
scope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Product");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
// Display the remote computer information
Console.WriteLine("Name : {0}", m["Name"]);
if (m["Name"] == appname)
{
Console.WriteLine(appname + " found and will be uninstalled... but how");
//need to uninstall this app...
}
}
}