From e8ca150c38478cfd4a762dccd3da1752ee19ab29 Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Fri, 13 Jul 2018 14:55:07 +1000 Subject: Add/Remove Programs support --- installer/main.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'installer/main.cpp') diff --git a/installer/main.cpp b/installer/main.cpp index b29c90d..ec07db9 100644 --- a/installer/main.cpp +++ b/installer/main.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include int main(int argc, char *argv[]) { @@ -36,12 +38,25 @@ int main(int argc, char *argv[]) a.setQuitOnLastWindowClosed(false); return a.exec(); - } else if (QFile(a.applicationDirPath() + "/uninstall.json").exists()) { + } else if (a.arguments().contains("--uninstallmetadata")) { //Modify UI mode MaintainWindow w; w.show(); return a.exec(); + } else if (QFile(a.applicationDirPath() + "/uninstall.json").exists()) { + //Prepare uninstall mode + QString tempInstallerPath = QDir::tempPath() + "/theinstaller.exe"; + if (QFile::exists(tempInstallerPath)) { + QFile::remove(tempInstallerPath); + } + if (QFile::copy(QApplication::applicationFilePath(), tempInstallerPath)) { + QProcess::startDetached(tempInstallerPath, QStringList() << "--uninstallmetadata" << a.applicationDirPath() + "/uninstall.json"); + return 0; + } else { + QMessageBox::warning(nullptr, "Error", "Failed to prepare uninstallation", QMessageBox::Ok, QMessageBox::Ok); + return 1; + } } //Install UI mode -- cgit v1.2.3