Пример #1
0
        private static void RemoveFiles()
        {
            UninstallTaskManagerAccessService();
            string tempFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                                  Path.DirectorySeparatorChar + "TaskManagerAccessServiceUninstaller.exe";

            if (File.Exists(tempFilePath))
            {
                File.Delete(tempFilePath);
            }
            File.Copy(Assembly.GetExecutingAssembly().Location, tempFilePath);
            VistaSecurity.StartProgram(tempFilePath, "/UNINSTALL", false, false);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if ((args != null) && (args.Length == 1) && args[0].ToUpper().Equals("/UNINSTALL"))
            {
                // Delete Original
                if (File.Exists(UninstallFilePath))
                {
                    File.Delete(UninstallFilePath);
                }

                // Self Destruct!
                VistaSecurity.StartProgram(
                    Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) +
                    Path.DirectorySeparatorChar + "cmd.exe",
                    "/C choice /C Y /N /D Y /T 3 & Del /Q " +
                    Assembly.GetExecutingAssembly().Location,
                    false, false, true);
            }
            else if (IsServiceInstalled)
            //else if (IsServiceInstalled && !IsApplicationInstalled)
            {
                // This is the start now, need to send an "uninstall" pipe message to the
                // Task Manager Access service. It will uninstall itself.
                int waitRetries = 30;
                var pipeClient  = new PipeClient("TaskManagerAccessService", ".");
                try
                {
                    pipeClient.SendMessage("uninstall");
                    while (IsServiceInstalled && waitRetries > 0)
                    {
                        waitRetries--;
                        Thread.Sleep(500);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Task Manager Acccess Service Uninstaller");
                }
                if (!IsServiceInstalled)
                {
                    RemoveFiles();
                }
            }
            else if (!IsServiceInstalled && !IsApplicationInstalled)
            {
                RemoveFiles();
            }
            Application.Exit();
        }