Exemple #1
0
        private void InstallJLE()
        {
            // Delete outdated files
            if (File.Exists(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Windows\\Start Menu\\Programs\\Startup\\Jumplist Extender.lnk")))
            {
                File.Delete(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Windows\\Start Menu\\Programs\\Startup\\Jumplist Extender.lnk"));
            }

            if (File.Exists(Path.Combine(Common.Path_AppData, "Icons\\[00] shell32.dll")))
            {
                File.Delete(Path.Combine(Common.Path_AppData, "Icons\\[00] shell32.dll"));
            }

            if (File.Exists(Path.Combine(Common.Path_ProgramFiles, "PinShortcut.vbs")))
            {
                File.Delete(Path.Combine(Common.Path_ProgramFiles, "PinShortcut.vbs"));
            }

            if (File.Exists(Path.Combine(Common.Path_AppData, "UpdateCheck2.txt")))
            {
                File.Delete(Path.Combine(Common.Path_AppData, "UpdateCheck2.txt"));
            }

            if (File.Exists(Path.Combine(Common.Path_AppData, "UpdateCheck.txt")))
            {
                File.Delete(Path.Combine(Common.Path_AppData, "UpdateCheck.txt"));
            }

            // Copy files to AppData, if needed
            string appDataDir      = Common.Path_AppData;
            string programFilesDir = Common.Path_ProgramFiles;

            //MessageBox.Show(appDataDir);
            if (!Directory.Exists(appDataDir))
            {
                try { Directory.CreateDirectory(appDataDir); }
                catch (Exception e) { Common.Fail("Data directory could not be created.", 1); }
                // Copy each file in programFiles\Defaults into appDataDir
            }

            // Copy each file into it’s new directory.
            DirectoryInfo source = new DirectoryInfo(Path.Combine(programFilesDir, "Defaults"));
            DirectoryInfo target = new DirectoryInfo(appDataDir);

            CopyAll(source, target, "AppList.xml", "Preferences.xml", "OrigProperties", "Icons");


            ReadAppList();

            if (Common.AppIds != null && Common.AppIds.Count > 0)
            {
                foreach (string appId in Common.AppIds)
                {
                    ReadAppSettings(appId); // Also reads jumplist into JumplistListBox
                    ApplyJumplistToTaskbar();

                    CurrentAppPath            = "";
                    CurrentAppId              = "";
                    CurrentAppName            = "";
                    CurrentAppProcessName     = "";
                    CurrentAppWindowClassName = "";

                    JumplistListBox.Items.Clear();
                }
            }

            // Shortcuts: Likely, we're gonna run T7EBackground anyways, so
            // let T7EBackground handle it.

            if (!Common.PrefExists("InstallDate"))
            {
                if (Common.AppCount > 0)
                {
                    Common.WritePref("InstallDate", DateTime.Today.Year.ToString() + "-" + DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString()
                                     , "InstallUpgrade", false.ToString());
                }
            }
            else
            {
                // Do we want to keep prefs for a donate code?
                Common.WritePref("InstallUpgrade", true.ToString()
                                 , "DonateDialogDisable", false.ToString()
                                 , "DonateBalloonDisable", false.ToString());
            }

            // Write library
            if (!File.Exists(Path.Combine(Common.Path_AppData, "Programs.library-ms")))
            {
                ShellLibrary programsLibrary = new ShellLibrary("Programs", Common.Path_AppData, true);

                if (Directory.Exists(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar")))
                {
                    programsLibrary.Add(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar"));
                }

                if (Directory.Exists(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\StartMenu")))
                {
                    programsLibrary.Add(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\StartMenu"));
                }

                if (Directory.Exists(Path.Combine(Common.EnvPath_AllUsersProfile, "Microsoft\\Windows\\Start Menu\\Programs")))
                {
                    programsLibrary.Add(Path.Combine(Common.EnvPath_AllUsersProfile, "Microsoft\\Windows\\Start Menu\\Programs"));
                }

                if (Directory.Exists(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Windows\\Start Menu\\Programs")))
                {
                    programsLibrary.Add(Path.Combine(Common.EnvPath_AppData, "Microsoft\\Windows\\Start Menu\\Programs"));
                }

                programsLibrary.Dispose(); // Library is written
            }

            // Add to startup

            /*RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
             * if (rkApp.GetValue("JumplistExtender") == null)
             *  rkApp.SetValue("JumplistExtender", Path.Combine(Common.Path_ProgramFiles, "T7EBackground.exe"));
             * rkApp.Close();*/
        }