映射网络驱动器无法使用 WMI 访问

发布于 2024-08-17 08:11:10 字数 1582 浏览 1 评论 0原文

我有两台机器,Machine1 和 Machine2。我已将 Machine1 中的 Machine2 中的一个共享文件夹映射为 Z。 我启动了一个应用程序,例如 App1,它列出了机器的所有驱动器,并且该应用程序位于 Machine1 中。我从 Machine1 启动了这个 App1,并且获得了所有驱动器 包括映射驱动器“Z”。但是当我使用 WMI [Windows Management Instrumentation.dll] 从 Machine2 启动位于 Machine1 中的 App1 时。下面给出了用于 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。

I have two machines, Say Machine1 and Machine2. I have mapped one shared folder in Machine2 in Machine1 as Z.
I started one application say App1 which list all drives of machine and the application is in Machine1. I started this App1 from Machine1 and I got all my drives
Including the mapped drive 'Z'. But when I Started the App1 which is in Machine1 from Machine2 using WMI [Windows Management Instrumentation. Code used for WMI communication is given below.]. App1 lists all drives except the mapped network drive 'Z'.
Is there any possible way to list out all drives of Machine1 even if I start App1 from Machine2 using 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 );
    }
}

Me trying using .Net 2.0 Windows.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如日中天 2024-08-24 08:11:10

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

Mapped drives are a per-user setting. When you run the app from the other machine, it probably uses a different user account.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文