internal void OpenWindowsUpdateLog(string username, string password) { Logger.EnteringMethod(); string uncPath = @"\\" + this.Name + @"\C$\Windows"; string remoteFile = "WindowsUpdate.log"; string localPath = GetTemporaryFolder() + this.Name + "-" + Guid.NewGuid() + ".txt"; NetUse netUse = new NetUse(); if (netUse.Mount(string.Empty, uncPath, username, password)) { if (System.IO.File.Exists(uncPath + "\\" + remoteFile)) { try { string remotePath = uncPath + "\\" + remoteFile; System.IO.File.Copy(remotePath, localPath); System.Diagnostics.ProcessStartInfo process = new System.Diagnostics.ProcessStartInfo(Properties.Settings.Default.OpenWindowsUpdateLogWith, "\"" + localPath + "\""); System.Diagnostics.Process.Start(process); System.Threading.Thread.Sleep(3000); System.IO.File.Delete(localPath); netUse.UnMount(uncPath); } catch (Exception ex) { Logger.Write("**** " + ex.Message); } } } }
private bool CheckTargetDirectory(string remoteDirectory, string username, string password) { Logger.EnteringMethod(remoteDirectory); NetUse netUse = new NetUse(); try { if (netUse.Mount(string.Empty, @"\\" + this.Name + @"\" + remoteDirectory, username, password)) { if (System.IO.File.Exists(@"\\" + this.Name + @"\" + remoteDirectory + @"\InstallPendingUpdates.exe")) { System.Diagnostics.FileVersionInfo remoteFileInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(@"\\" + this.Name + @"\" + remoteDirectory + @"\InstallPendingUpdates.exe"); System.Diagnostics.FileVersionInfo localFileInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo("InstallPendingUpdates.exe"); if (remoteFileInfo.FileVersion != localFileInfo.FileVersion) { CopyFile(remoteDirectory, "InstallPendingUpdates.exe"); } } else { CopyFile(remoteDirectory, "InstallPendingUpdates.exe"); } if (System.IO.File.Exists(@"\\" + this.Name + @"\" + remoteDirectory + @"\Interop.WUApiLib.dll")) { System.Diagnostics.FileVersionInfo remoteFileInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(@"\\" + this.Name + @"\" + remoteDirectory + @"\Interop.WUApiLib.dll"); System.Diagnostics.FileVersionInfo localFileInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo("Interop.WUApiLib.dll"); if (remoteFileInfo.FileVersion != localFileInfo.FileVersion) { CopyFile(remoteDirectory, "Interop.WUApiLib.dll"); } } else { CopyFile(remoteDirectory, "Interop.WUApiLib.dll"); } netUse.UnMount(@"\\" + this.Name + @"\" + remoteDirectory); return(true); } } catch (Exception ex) { Logger.Write("**** " + ex.Message); } return(false); }