private Status DoInstall(string argument) { Status = Status.Working; //var result = Processes.Open("pnputil.exe", argument); ////http://www.hiteksoftware.com/knowledge/articles/049.htm using (var session = DismApi.OpenOnlineSession()) { try { DismApi.AddDriver(session, Location, false); return(Status.Success); } catch (Exception Ex) { _tooltip = Ex.Message; return(Status.Failed); } //if (!string.IsNullOrWhiteSpace(err)) //{ // MessageBox.Show(err, "Error"); // //} // return Status.Failed; //} } //if (result == 0) //{ return(Status.Success); //} /// return Status.Failed; }
public bool AddDriver(string infFullPath, bool install) { switch (this.Type) { case DriverStoreType.Online: return(SetupAPI.AddDriver(infFullPath, install)); case DriverStoreType.Offline: DismApi.Initialize(DismLogLevel.LogErrors); try { using (DismSession session = this.GetSession()) { DismApi.AddDriver(session, infFullPath, false); } } finally { DismApi.Shutdown(); } return(true); default: throw new NotSupportedException(); } }
public bool AddDriver(string infFullPath, bool install) { switch (this.Type) { case DriverStoreType.Online: try { SetupAPI.AddDriver(infFullPath, install); } catch (Win32Exception ex) { Trace.TraceError(ex.ToString()); return(false); } return(true); case DriverStoreType.Offline: try { DismApi.Initialize(DismLogLevel.LogErrors); try { using (DismSession session = this.GetSession()) { DismApi.AddDriver(session, infFullPath, false); } } finally { DismApi.Shutdown(); } } catch (DismRebootRequiredException) { return(true); } catch (DismException ex) { Trace.TraceError(ex.ToString()); return(false); } return(true); default: throw new NotSupportedException(); } }
public bool AddDriver(string infFullPath, bool install) { DismApi.Initialize(DismLogLevel.LogErrors); try { using (DismSession session = DismApi.OpenOnlineSession()) { DismApi.AddDriver(session, infFullPath, false); } } finally { DismApi.Shutdown(); } return(true); }
private void addDriverMountedButton_Click(object sender, EventArgs e) { if (driverMountPathTextBox.Text == "PathToDriver" || driverMountPathTextBox.Text == "" || driverMountPathTextBox.Text == null) { MessageBox.Show("Please Enter PathToDriver"); } else { DismApi.Initialize(DismLogLevel.LogErrors); string driverPath = driverMountPathTextBox.Text; Task.Factory.StartNew(() => { Task.Run(() => { if (this.InvokeRequired) { this.Invoke((MethodInvoker)(() => { loadingPanel.Visible = true; mainPanel.Enabled = false; mainPanel.Visible = false; })); } else { loadingPanel.Visible = true; mainPanel.Enabled = false; mainPanel.Visible = false; } }); try { using (DismSession session = DismApi.OpenOfflineSession(MountPath)) { DismApi.AddDriver(session, driverPath, true); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { if (this.InvokeRequired) { this.Invoke((MethodInvoker)(() => { loadingPanel.Visible = false; mainPanel.Enabled = true; mainPanel.Visible = true; })); } else { loadingPanel.Visible = false; mainPanel.Enabled = true; mainPanel.Visible = true; } DismApi.Shutdown(); } }); } }