映射网络驱动器无法使用 WMI 访问
我有两台机器,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
映射驱动器是每个用户的设置。当您从另一台计算机运行该应用程序时,它可能使用不同的用户帐户。
Mapped drives are a per-user setting. When you run the app from the other machine, it probably uses a different user account.