0
我有兩臺機器,說Machine1和Machine2。我已經將Machine1中的Machine2中的一個共享文件夾映射爲Z. 我啓動了一個應用程序,稱App1列出了機器的所有驅動器,並且該應用程序位於Machine1中。我從Machine1啓動了此App1,並獲得了所有驅動器 包括映射驅動器'Z'。但是當我使用WMI啓動Machine2中Machine1中的App1時[Windows Management Instrumentation。用於WMI通信的代碼如下所示。]。 App1列出除映射網絡驅動器'Z'之外的所有驅動器。 是否有任何可能的方式列出Machine1的所有驅動器,即使我使用WMI從Machine2啓動App1。映射網絡驅動器無法訪問使用WMI
// Code to start application on remote machine.
ManagementPath path = new ManagementPath(string.Format(@"\\{0}\root\cimv2:Win32_Process", machine));
try
{
// Connect options include user name and password of the remote machine to connect.
ConnectionOptions options = new ConnectionOptions();
options.Username = UserName;
options.Password = Password;
ManagementPath path = new ManagementPath(string.Format(@"\\{0}\root\cimv2:Win32_Directory", machine));
ManagementScope scope = new ManagementScope(path, options);
if(scope != null)
{
ObjectGetOptions getOptions = new ObjectGetOptions();
ManagementClass cimInstance = new ManagementClass(scope, path, getOptions);
// Fill the necessary parameters for Create method of Win32 Process.
ManagementBaseObject inParams = cimInstance.GetMethodParameters("Create");
// Commandline is the full path of the application including the exe name.
inParams["CommandLine"] = commandLine;
// Execute the method and obtain the return values.
cimInstance.InvokeMethod("Create", inParams, null);
}
}
我嘗試使用.Net 2.0 Windows。