static Guid uninstallGuid = new Guid("ba21a8d1-e588-48ab-bf4c-b37e8fb3708e"); // this was randomly generated public static void UninstallK2VrLegacy(Pages.Install installPage) { string path = k2vrLegacyDefaultPath; if (Directory.Exists(path)) { installPage.Log("K2VR Legacy installation found...", false); if (MessageBox.Show("Legacy K2VR installation found!" + Environment.NewLine + "Do you wish to uninstall it? (recommended)", "Legacy K2VR found", MessageBoxButton.YesNo) == MessageBoxResult.Yes && MessageBox.Show("Uninstalling K2VR legacy will delete the folder \"" + path + "\" and all its contents", "Confirm uninstall", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { installPage.Log("Deleting...", false); Directory.Delete(path, true); installPage.Log("Removing start menu shortcuts...", false); string startMenuFolder = Path.Combine("C:\\", "ProgramData", "Microsoft", "Windows", "Start Menu", "Programs", "KinectToVR"); if (Directory.Exists(startMenuFolder)) { File.Delete(Path.Combine(startMenuFolder, "KinectToVR (Xbox 360).lnk")); File.Delete(Path.Combine(startMenuFolder, "KinectToVR (Xbox One).lnk")); try { Directory.Delete(startMenuFolder, false); } catch (IOException) { } } installPage.Log("Done!"); } else { installPage.Log("Keeping!"); } } else { installPage.Log("Not found!"); } string ovrieFolder = Path.Combine("C:\\", "Program Files", "OpenVR-InputEmulator"); if (Directory.Exists(ovrieFolder)) { if (MessageBox.Show("OpenVR Input Emulator found!" + Environment.NewLine + "Do you wish to uninstall it? (recommended)", "Uninstall OpenVR Input Emulator?", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { installPage.Log("Uninstalling OpenVR Input Emulator...", false); // copy installer to temp File.Copy(Path.Combine(ovrieFolder, "Uninstall.exe"), Path.Combine(App.downloadDirectory, "Uninstall.exe"), true); Process.Start(Path.Combine(App.downloadDirectory, "Uninstall.exe"), "_?=" + ovrieFolder + "\\").WaitForExit(); installPage.Log("Done!"); } } }
static Guid uninstallGuid = new Guid("ba21a8d1-e588-48ab-bf4c-b37e8fb3708e"); // this was randomly generated public static void UninstallK2VrLegacy(Pages.Install installPage) { string path = k2vrLegacyDefaultPath; if (Directory.Exists(path)) { installPage.Log("K2VR Legacy installation found...", false); if (MessageBox.Show("Legacy K2VR installation found!" + Environment.NewLine + "Do you wish to uninstall it? (recommended)", "Legacy K2VR found", MessageBoxButton.YesNo) == MessageBoxResult.Yes && MessageBox.Show("Uninstalling K2VR legacy will delete the folder \"" + path + "\" and all its contents", "Confirm uninstall", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { installPage.Log("Deleting...", false); Directory.Delete(path, true); installPage.Log("Removing start menu shortcuts...", false); string startMenuFolder = Path.Combine("C:\\", "ProgramData", "Microsoft", "Windows", "Start Menu", "Programs", "KinectToVR"); if (Directory.Exists(startMenuFolder)) { File.Delete(Path.Combine(startMenuFolder, "KinectToVR (Xbox 360).lnk")); File.Delete(Path.Combine(startMenuFolder, "KinectToVR (Xbox One).lnk")); try { Directory.Delete(startMenuFolder, false); } catch (IOException) { } } installPage.Log("Done!"); } else { installPage.Log("Keeping!"); } } else { installPage.Log("Not found!"); } }
public static bool UninstallAllK2EX(Pages.Install installPage) { var paths = FindK2EX(); foreach (KeyValuePair <string, K2EXInstallProperties> pair in paths) { string path = pair.Key; if (path == App.state.GetFullInstallationPath()) { continue; } installPage.Log("Found old installation at \"" + path + "\"...", false); if (pair.Value.DriverRegistered || pair.Value.AppConfigRegistered) { if (MessageBox.Show("K2EX appears to also be installed in " + "\"" + path + "\"" + ". Do you wish to disable it?", "Already installed", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { installPage.Log("Disabling...", false); UnregisterK2EX(path); } else { MessageBox.Show("Multiple installations of K2EX would interfere with each other." + Environment.NewLine + "Restart this installer to try again" + Environment.NewLine + "Please join our Discord server for further assistance (link on www.k2vr.tech)"); installPage.Cancel(); return(false); } } DeleteK2EXFolder(path); } if (Directory.Exists(App.state.copiedDriverPath)) { installPage.Log("Deleting copied driver...", false); var ovrDriverFiles = OpenVrDriverFiles.Read(); foreach (string file in ovrDriverFiles.Files) { string delFile = Path.Combine(App.state.copiedDriverPath, file); if (File.Exists(delFile)) { File.Delete(delFile); } } for (int i = ovrDriverFiles.Folders.Count - 1; i >= 0; i--) { string delDir = Path.Combine(App.state.copiedDriverPath, ovrDriverFiles.Folders[i]); if (Directory.Exists(delDir)) { Directory.Delete(delDir, false); } } try { Directory.Delete(App.state.copiedDriverPath, false); } catch (IOException) { } installPage.Log("Deleted...", false); } if (Directory.Exists(App.state.GetFullInstallationPath())) { installPage.Log("Removing previous version...", false); if (MessageBox.Show("KinectToVR appears to be already installed in \"" + App.state.GetFullInstallationPath() + "\"." + Environment.NewLine + "Do you wish to update this installation?", "Confirm update", MessageBoxButton.YesNo) != MessageBoxResult.Yes || !DeleteK2EXFolder(App.state.GetFullInstallationPath())) { // We need to abort because we can't unzip into a dir with files in it MessageBox.Show("Cannot install two versions of KinectToVR into the same directory." + Environment.NewLine + "Either uninstall the old version or select another install directory." + Environment.NewLine + "Restart this installer to try again"); installPage.Cancel(); return(false); } } if (Directory.Exists(App.startMenuFolder)) { installPage.Log("Removing start menu shortcuts...", false); DeleteK2EXStartMenuShortcuts(); } return(true); }
static Guid uninstallGuid = new Guid("ba21a8d1-e588-48ab-bf4c-b37e8fb3708e"); // this was randomly generated public static void UninstallK2VrLegacy(Pages.Install installPage) { string path = k2vrLegacyDefaultPath; if (Directory.Exists(path)) { installPage.Log("K2VR Legacy installation found...", false); if (MessageBox.Show(Properties.Resources.install_legacy_k2vr_remove, Properties.Resources.install_legacy_k2vr_remove_title, MessageBoxButton.YesNo) == MessageBoxResult.Yes && MessageBox.Show(Properties.Resources.install_legacy_k2vr_confirm.Replace("{0}", path), Properties.Resources.install_legacy_k2vr_confirm_title, MessageBoxButton.OKCancel) == MessageBoxResult.OK) { installPage.Log("Deleting...", true); // https://stackoverflow.com/a/11523266/4672279 // this should fix msvcp140.dll access denied errors. System.IO.DirectoryInfo di = new DirectoryInfo(path); foreach (FileInfo file in di.GetFiles()) { try { // we need to manually set file attribs before deleting. File.SetAttributes(file.FullName, FileAttributes.Normal); file.Delete(); } catch (Exception) { installPage.Log($"Couldn't delete {file.FullName}!", true); } } try { Directory.Delete(path, true); } catch (Exception) { installPage.Log($"Couldn't delete {path}! try removing it yourself.", true); } installPage.Log("Removing start menu shortcuts...", false); string startMenuFolder = Path.Combine("C:\\", "ProgramData", "Microsoft", "Windows", "Start Menu", "Programs", "KinectToVR"); if (Directory.Exists(startMenuFolder)) { File.Delete(Path.Combine(startMenuFolder, "KinectToVR (Xbox 360).lnk")); File.Delete(Path.Combine(startMenuFolder, "KinectToVR (Xbox One).lnk")); try { Directory.Delete(startMenuFolder, false); } catch (IOException) { } } installPage.Log("Done!"); } else { installPage.Log("Keeping!"); } } else { installPage.Log("Not found!"); } string ovrieFolder = Path.Combine("C:\\", "Program Files", "OpenVR-InputEmulator"); if (File.Exists(Path.Combine(ovrieFolder, "Uninstall.exe"))) { if (MessageBox.Show(Properties.Resources.install_remove_ovrie, Properties.Resources.install_remove_ovrie_title, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { installPage.Log("Uninstalling OpenVR Input Emulator...", false); // copy installer to temp File.Copy(Path.Combine(ovrieFolder, "Uninstall.exe"), Path.Combine(App.downloadDirectory, "Uninstall.exe"), true); Process.Start(Path.Combine(App.downloadDirectory, "Uninstall.exe"), "_?=" + ovrieFolder + "\\").WaitForExit(); installPage.Log("Done!"); } } }
public static bool UninstallAllK2EX(Pages.Install installPage) { var paths = FindK2EX(); foreach (KeyValuePair <string, K2EXInstallProperties> pair in paths) { string path = pair.Key; if (path == App.state.GetFullInstallationPath()) { continue; } installPage.Log("Found old installation at \"" + path + "\"...", false); if (pair.Value.DriverRegistered || pair.Value.AppConfigRegistered) { if (MessageBox.Show(Properties.Resources.installer_previous_disable.Replace("{0}", path), Properties.Resources.installer_previous_disable_title, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { installPage.Log("Disabling...", false); UnregisterK2EX(path); } else { MessageBox.Show(Properties.Resources.install_multiple_k2ex); installPage.Cancel(); return(false); } } DeleteK2EXFolder(path); } if (Directory.Exists(App.state.copiedDriverPath)) { installPage.Log("Deleting copied driver...", false); var ovrDriverFiles = OpenVrDriverFiles.Read(); foreach (string file in ovrDriverFiles.Files) { string delFile = Path.Combine(App.state.copiedDriverPath, file); if (File.Exists(delFile)) { File.Delete(delFile); } } for (int i = ovrDriverFiles.Folders.Count - 1; i >= 0; i--) { string delDir = Path.Combine(App.state.copiedDriverPath, ovrDriverFiles.Folders[i]); if (Directory.Exists(delDir)) { Directory.Delete(delDir, false); } } try { Directory.Delete(App.state.copiedDriverPath, false); } catch (IOException) { } installPage.Log("Deleted...", false); } if (Directory.Exists(App.state.GetFullInstallationPath())) { installPage.Log("Removing previous version...", false); if (MessageBox.Show(Properties.Resources.install_update.Replace("{0}", App.state.GetFullInstallationPath()), Properties.Resources.install_update_title, MessageBoxButton.YesNo) != MessageBoxResult.Yes || !DeleteK2EXFolder(App.state.GetFullInstallationPath())) { // We need to abort because we can't unzip into a dir with files in it MessageBox.Show(Properties.Resources.install_existing_folder_fail); installPage.Cancel(); return(false); } } if (Directory.Exists(App.startMenuFolder)) { installPage.Log("Removing start menu shortcuts...", false); DeleteK2EXStartMenuShortcuts(); } return(true); }