public void TestListApps() { if (!WindowsUtils.IsWindowsVista) Assert.Ignore("Restart Manager only available on Windows Vista or higher"); using (var restartManager = new WindowsRestartManager()) { restartManager.RegisterResources(@"C:\Windows\explorer.exe"); restartManager.ListApps(new SilentTaskHandler()); } }
public void TestListApps() { Skip.IfNot(WindowsUtils.IsWindowsVista, reason: "Restart Manager only available on Windows Vista or higher"); using (var restartManager = new WindowsRestartManager()) { restartManager.RegisterResources(@"C:\Windows\explorer.exe"); restartManager.ListApps(new SilentTaskHandler()); } }
/// <summary> /// Uses the <see cref="WindowsRestartManager"/> to shut down applications holding references to files we want to update. /// </summary> private void RestartManagerShutdown() { if (!WindowsUtils.IsWindowsVista) return; _restartManager = new WindowsRestartManager(); _restartManager.RegisterResources(GetFilesToWrite()); _restartManager.RegisterResources(GetFilesToDelete()); _restartManager.ShutdownApps(new SilentTaskHandler()); }
/// <summary> /// Closes any open <see cref="WindowsRestartManager"/> sessions. /// </summary> private void RestartManagerFinish() { if (_restartManager == null) return; _restartManager.Dispose(); _restartManager = null; }
/// <summary> /// Uses <see cref="WindowsRestartManager"/> to close any applications that have open references to the specified <paramref name="files"/> if possible and removes read-only attributes. /// </summary> /// <remarks>Closed applications will be restarted by <see cref="Dispose"/>.</remarks> protected void UnlockFiles(IEnumerable<string> files) { if (WindowsUtils.IsWindows) { var fileArray = files.ToArray(); if (fileArray.Length == 0) return; if (WindowsUtils.IsWindowsVista) { if (_restartManager == null) _restartManager = new WindowsRestartManager(); _restartManager.RegisterResources(fileArray); if (_restartManager.ListApps(Handler).Length == 0) NoRestart = true; _restartManager.ShutdownApps(Handler); } foreach (string path in fileArray) new FileInfo(path).IsReadOnly = false; } }