C# 映射的网络驱动器无法';无法使用WMI访问
我有两台机器,比如说机器1和机器2。我已将Machine2中的一个共享文件夹映射为Machine1中的Z。 我启动了一个应用程序,比如App1,它列出了机器的所有驱动器,该应用程序位于Machine1中。我从Machine1启动了这个App1,我得到了所有的驱动器 包括映射的驱动器“Z”。但当我使用WMI从Machine2启动Machine1中的App1时[Windows Management Instrumentation.用于WMI通信的代码如下所示。]。App1列出了除映射的网络驱动器“Z”之外的所有驱动器。 是否有任何可能的方法列出Machine1的所有驱动器,即使我使用WMI从Machine2启动App1C# 映射的网络驱动器无法';无法使用WMI访问,c#,winforms,mapping,wmi,C#,Winforms,Mapping,Wmi,我有两台机器,比如说机器1和机器2。我已将Machine2中的一个共享文件夹映射为Machine1中的Z。 我启动了一个应用程序,比如App1,它列出了机器的所有驱动器,该应用程序位于Machine1中。我从Machine1启动了这个App1,我得到了所有的驱动器 包括映射的驱动器“Z”。但当我使用WMI从Machine2启动Machine1中的App1时[Windows Management Instrumentation.用于WMI通信的代码如下所示。]。App1列出了除映射的网络驱动器“Z
// 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。映射驱动器是按用户设置的。当您从另一台计算机运行应用程序时,它可能使用不同的用户帐户