LAN内のコンピューターの共有フォルダーにプログラムをインストールできるようにする必要があります。
まず、コンピューターで共有されているフォルダーを確認してから、インストールを続行するのに十分なディスク容量があるかどうかを確認する必要があります。
これが私の方法です。
public static void FindShares()
{
try
{
ConnectionOptions options = new ConnectionOptions();
options.Authentication = AuthenticationLevel.PacketPrivacy;
options.Impersonation = ImpersonationLevel.Impersonate;
string path = "\\\\COMPUTERNAME\\root\\cimv2";
ManagementScope scope = new ManagementScope(path, options);
scope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Share");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
// Display shared folder information
Console.WriteLine("Share Name : {0}", m["Name"]);
Console.WriteLine("Share Path : {0}", m["Path"]);
Console.WriteLine("AccessMask: {0}", m["AccessMask"]);
Console.WriteLine("Type: {0}", m["Type"]);
Console.WriteLine("Status : {0}", m["Status"]);
Console.WriteLine();
}
string line;
line = Console.ReadLine();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
これを実行すると、次のエラーが発生します: アクセスが拒否されました。(HRESULTからの例外:0x80070005(E_ACCESSDENIED))
私は自分のインペロネーションを別の方法で設定する必要があると思いますが、方法がわかりません。
ご協力ありがとうございました。