【问题标题】:Mapped Network drive couldn't access using WMI映射网络驱动器无法使用 WMI 访问
【发布时间】:2010-01-08 09:39:15
【问题描述】:

我有两台机器,Say Machine1 和 Machine2。我已将 Machine1 中 Machine2 中的一个共享文件夹映射为 Z。 我启动了一个应用程序 App1,它列出了机器的所有驱动器,并且该应用程序位于 Machine1 中。我从 Machine1 启动了这个 App1,我得到了所有的驱动器 包括映射驱动器“Z”。但是当我使用 WMI [Windows Management Instrumentation.下面给出了用于 WMI 通信的代码。]。 App1 列出了除映射网络驱动器“Z”之外的所有驱动器。 即使我使用 WMI 从 Machine2 启动 App1,是否有任何可能的方法列出 Machine1 的所有驱动器。

// 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。

【问题讨论】:

    标签: c# winforms mapping wmi


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多