/// <summary> /// Uninstalls the driver. /// </summary> /// <param name="componentId">The component identifier.</param> /// <param name="afterReboot">if set to <c>true</c>, requires a reboot for the changes to take affect.</param> /// <param name="errorCode">The error code.</param> /// <returns><c>true</c> if uninstalled, <c>false</c> otherwise.</returns> public bool UninstallDriver(string componentId, out bool afterReboot, out uint errorCode) { using (var snetCfg = new NetCfg("")) { return(snetCfg.Uninstall(componentId, out afterReboot, out errorCode)); } }
/// <summary> /// Installs the driver. /// </summary> /// <param name="rootPath">The root path, this should contain the original folder structure.</param> /// <param name="infFileName">Name of the inf file.</param> /// <param name="componentId">The component identifier.</param> /// <param name="afterReboot">if set to <c>true</c>, requires a reboot for the changes to take affect.</param> /// <param name="errorCode">The error code.</param> /// <returns><c>true</c> if installed, <c>false</c> otherwise.</returns> public bool InstallDriver(string rootPath, string infFileName, string componentId, out bool afterReboot, out uint errorCode) { var subFolder = ""; if (OperatingSystem.IsWin10()) { subFolder = "win10"; } else if (OperatingSystem.IsWin8() || OperatingSystem.IsWin81()) { subFolder = "win8"; } else if (OperatingSystem.IsWin7()) { subFolder = "win7"; } else if (OperatingSystem.IsWinVista()) { subFolder = "vista"; } var architecture = Environment.Is64BitOperatingSystem ? "amd64" : "i386"; var path = Path.Combine(Path.Combine(rootPath, subFolder), architecture); using (var snetCfg = new NetCfg(path)) { return(snetCfg.Install(infFileName, componentId, out afterReboot, out errorCode)); } }
/// <summary> /// Determines whether the driver is installed. /// </summary> /// <param name="componentId">The component identifier.</param> /// <returns><c>true</c> if the driver is installed; otherwise, <c>false</c>.</returns> public bool IsDriverInstalled(string componentId = "nt_ndisrd") { using (var snetCfg = new NetCfg("")) { return(snetCfg.IsInstalled(componentId)); } }