Beispiel #1
0
        private static bool UninstallApplication()
        {
            try {
                IO.PathContainer uninstallerPath = Mod.GetUninstallerFullPath();

                using (Process uninstallProcess = new Process()
                {
                    StartInfo =
                    {
                        FileName  = uninstallerPath.GetPath(),
                        Arguments = "-q " + (Entry.Silent ? "-s " : " ") + "-p -t \"" + Paths.Sims4Path + "\"",
                    }
                }) {
                    uninstallProcess.Start();
                    uninstallProcess.WaitForExit();

                    if (uninstallProcess.ExitCode == 1)
                    {
                        return(false);
                    }

                    if (File.Exists(uninstallerPath.GetPath()))
                    {
                        File.Delete(uninstallerPath.GetPath());
                    }

                    IO.CloseDirectory(Path.Combine(Paths.ModsPath.GetPath(), uninstallerPath.GetRelativePathTo(Paths.ModsPath).GetPath(1)));
                }
            } catch (Exception e) {
                if (!Entry.Silent)
                {
                    Error errorDialog = new Error(Localization.GetString("UninstallFailure"), e.ToString());
                    errorDialog.ShowDialog();
                }

                return(false);
            }

            return(true);
        }
Beispiel #2
0
        private static bool CheckGame()
        {
            try {
                string sims4InstallPath = (string)Registry.GetValue(Registry.LocalMachine + @"\SOFTWARE\Wow6432Node\Maxis\The Sims 4", "Install Dir", null);

                if (sims4InstallPath == null)
                {
                    return(true);
                }

                IO.PathContainer sims4ApplicationPath   = new IO.PathContainer(Path.Combine(sims4InstallPath, "Game", "Bin", "TS4.exe"));
                IO.PathContainer sims464ApplicationPath = new IO.PathContainer(Path.Combine(sims4InstallPath, "Game", "Bin", "TS4_x64.exe"));

                Process[] processes = Process.GetProcesses();

                bool running = false;

                for (int processIndex = 0; processIndex < processes.Length; processIndex++)
                {
                    try {
                        IO.PathContainer processPath = new IO.PathContainer(Processes.GetPath(processes[processIndex]));

                        if (!string.IsNullOrWhiteSpace(processPath.GetPath()))
                        {
                            if (processPath.Equals(sims4ApplicationPath) || processPath.Equals(sims464ApplicationPath))
                            {
                                running = true;
                                break;
                            }
                        }
                    } catch { }
                }

                if (running)
                {
                    MessageBox.Show(Localization.GetString("Sims4RunningText"));
                    return(false);
                }
            } catch (Exception e) {
                if (!Entry.Silent)
                {
                    Error errorDialog = new Error(Localization.GetString("CheckGameFailure"), e.ToString());
                    errorDialog.ShowDialog();
                }

                return(false);
            }

            return(true);
        }
Beispiel #3
0
        private static bool UninstallAntique()
        {
            IO.PathContainer identifyingFile = null;
            string           version         = null;

            try {
                identifyingFile = Antique.GetIdentifyingFile();
                version         = Antique.GetVersion();
            } catch (Exception e) {
                if (!Entry.Silent)
                {
                    Error errorDialog = new Error(Localization.GetString("UninstallAntiqueReadVersionFailure"), e.ToString());
                    errorDialog.ShowDialog();
                }

                return(false);
            }

            try {
                if (version != null)
                {
                    List <IO.PathContainer> files = null;

                    foreach (Mod.AntiqueFileList antiqueFileList in Mod.AntiqueFileLists)
                    {
                        if (antiqueFileList.Version == version)
                        {
                            files = antiqueFileList.GetFilesFullPaths();
                        }
                    }

                    if (files != null)
                    {
                        List <IO.PathContainer> fileRoots = new List <IO.PathContainer>();

                        bool removedIdentifyingFile = false;

                        for (int fileIndex = 0; fileIndex < files.Count; fileIndex++)
                        {
                            if (files[fileIndex].Equals(identifyingFile))
                            {
                                files.RemoveAt(fileIndex);
                                fileIndex--;
                                removedIdentifyingFile = true;
                                continue;
                            }

                            IO.PathContainer fileRoot = new IO.PathContainer(Path.Combine(Paths.ModsPath.GetPath(), files[fileIndex].GetRelativePathTo(Paths.ModsPath).GetPath(1)));

                            if (!fileRoots.Contains(fileRoot))
                            {
                                fileRoots.Add(fileRoot);
                            }
                        }

                        IO.DeleteFiles(files);

                        for (int fileRootIndex = 0; fileRootIndex < fileRoots.Count; fileRootIndex++)
                        {
                            IO.CloseDirectory(fileRoots[fileRootIndex].GetPath());
                        }

                        if (removedIdentifyingFile)
                        {
                            if (File.Exists(identifyingFile.GetPath()))
                            {
                                File.Delete(identifyingFile.GetPath());
                            }

                            IO.CloseDirectory(Path.Combine(Paths.ModsPath.GetPath(), identifyingFile.GetRelativePathTo(Paths.ModsPath).GetPath(1)));
                        }
                    }
                    else
                    {
                        if (!Entry.Silent)
                        {
                            string errorMessage = Localization.GetString("UninstallAntiqueUnknownVersionFailure");
                            Error  errorDialog  = new Error(errorMessage, errorMessage);
                            errorDialog.ShowDialog();
                        }

                        return(false);
                    }
                }
            } catch (Exception e) {
                if (!Entry.Silent)
                {
                    Error errorDialog = new Error(Localization.GetString("UninstallAntiqueDeleteFailure"), e.ToString());
                    errorDialog.ShowDialog();
                }

                return(false);
            }

            return(true);
        }