0

尝试使用已登录计算机的凭据编写 WMI 类函数以在任何计算机(远程或本地)上安装网络驱动器。

这是我为帮助台工作人员编写的一个大型项目的课程,用于在远程 PC 上进行第一线修复。技术人员输入机器名称或 IP 地址,应用程序连接到它,并允许技术人员单击几个按钮并修复一些基本项目,而无需远程 (VNC) 进入 PC。

我在整个互联网上都读过它比 WMI 更简单的方法,但由于应用程序的远程性质,我宁愿不使用本地 API 调用,也不想担心上传脚本并通过进程执行它开始。WMI 中也已经有其他功能,所以我想保持代码库相同。

基本思想是安装H://fileserver.example.com/$username

NetFixer 已经在生产中使用,所以我试图让我的代码保持整洁

在此处输入图像描述

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;

namespace WMIcontrols
{
  public class Remote
  {

   public string target;

   //Some code skipped here for simplicity sake... 

   public bool MountNetDrive(string DriveLetter, string MountLocation)
    {
      try
      {
          //Mount the network drive
          return true;
      }
      catch
      {
          //Mount Failed
          return false;
      }
    }
  }
}
4

1 回答 1

2

这不是使用 WMI,但会完成您想要的并且非常简单

System.Diagnostics.Process.Start("cmd", "/c net use x: \\fileserver.example.com /user:Username Password");
于 2012-11-08T00:07:28.497 回答