2010-01-08 215 views
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。

回答

0

映射驱动器是按用户设置的。当您从另一台机器运行应用程序时,它可能会使用不同的用户帐户。