RemoveShortcutsForExecutable() public method

public RemoveShortcutsForExecutable ( string exeName, ShortcutLocation locations ) : void
exeName string
locations ShortcutLocation
return void
Beispiel #1
0
        /// <summary>
        /// Execute when app is uninstalling
        /// </summary>
        /// <param name="version"><see cref="Version"/> version</param>
        private static void OnAppUninstall(Version version)
        {
            using (var manager = new UpdateManager(Constants.UpdateServerUrl))
            {
                manager.RemoveShortcutsForExecutable("Popcorn.exe", ShortcutLocation.Desktop);
                manager.RemoveShortcutsForExecutable("Popcorn.exe", ShortcutLocation.StartMenu);
                manager.RemoveShortcutsForExecutable("Popcorn.exe", ShortcutLocation.AppRoot);

                manager.RemoveUninstallerRegistryEntry();
            }
        }
 private static void onAppUninstall(Version version)
 {
     try {
         using (var mgr = new Squirrel.UpdateManager(null, "OutlookGoogleCalendarSync")) {
             log.Info("Removing shortcuts.");
             mgr.RemoveShortcutsForExecutable(Path.GetFileName(System.Windows.Forms.Application.ExecutablePath),
                                              Squirrel.ShortcutLocation.Desktop | Squirrel.ShortcutLocation.StartMenu);
             String startMenuFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "Paul Woolcock");
             Directory.Delete(startMenuFolder);
             log.Debug("Removing registry uninstall keys.");
             mgr.RemoveUninstallerRegistryEntry();
         }
         if (MessageBox.Show("Sorry to see you go!\nCould you spare 30 seconds for some feedback?", "Uninstalling OGCS",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             log.Debug("User opted to give feedback.");
             System.Diagnostics.Process.Start("https://docs.google.com/forms/d/e/1FAIpQLSfRWYFdgyfbFJBMQ0dz14patu195KSKxdLj8lpWvLtZn-GArw/viewform");
         }
         else
         {
             log.Debug("User opted not to give feedback.");
         }
         log.Info("Deleting directory " + Path.GetDirectoryName(Program.SettingsFile));
         try {
             log.Logger.Repository.Shutdown();
             log4net.LogManager.Shutdown();
             Directory.Delete(Path.GetDirectoryName(Program.SettingsFile), true);
         } catch (System.Exception ex) {
             try { log.Error(ex.Message); } catch { }
         }
     } catch (System.Exception ex) {
         log.Error("Problem encountered on app uninstall.");
         OGCSexception.Analyse(ex, true);
     }
 }
Beispiel #3
0
 private static void OnAppUninstall(Version version)
 {
     try
     {
         Log.InfoFormat("OnAppUninstall for version {0}", version);
         using (var updateManager = new UpdateManager(Program.PackageUrl, Program.PackageId))
         {
             updateManager.RemoveShortcutsForExecutable("Nuts.exe", ShortcutLocation.Desktop);
         }
     }
     catch (Exception exception)
     {
         Log.Error("OnAppUninstall encountered and exception", exception);
         throw;
     }
 }
Beispiel #4
0
        public void Deshortcut(string exeName, string shortcutArgs)
        {
            if (String.IsNullOrWhiteSpace(exeName)) {
                ShowHelp();
                return;
            }

            var appName = getAppNameFromDirectory();
            var defaultLocations = ShortcutLocation.StartMenu | ShortcutLocation.Desktop;
            var locations = parseShortcutLocations(shortcutArgs);

            using (var mgr = new UpdateManager("", appName)) {
                mgr.RemoveShortcutsForExecutable(exeName, locations ?? defaultLocations);
            }
        }
        public void Deshortcut(string exeName)
        {
            if (String.IsNullOrWhiteSpace(exeName)) {
                ShowHelp();
                return;
            }

            var appName = getAppNameFromDirectory();
            using (var mgr = new UpdateManager("", appName, FrameworkVersion.Net45)) {
                mgr.RemoveShortcutsForExecutable(exeName, ShortcutLocation.Desktop | ShortcutLocation.StartMenu);
            }
        }
        public void Deshortcut(string exeName, string shortcutArgs)
        {
            if (String.IsNullOrWhiteSpace(exeName)) {
                ShowHelp();
                return;
            }

            var appName = getAppNameFromDirectory();
            var defaultLocations = ShortcutLocation.StartMenu | ShortcutLocation.Desktop;
            var locations = parseShortcutLocations(shortcutArgs);

            // NB: Always basing the rootAppDirectory relative to ours allows us to create Portable
            // Applications
            var ourDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..");

            using (var mgr = new UpdateManager("", appName, FrameworkVersion.Net45, ourDir)) {
                mgr.RemoveShortcutsForExecutable(exeName, locations ?? defaultLocations);
            }
        }
Beispiel #7
0
        public static void OnAppUninstall(Version version)
        {
            var exePath = Assembly.GetEntryAssembly().Location;
            string appName = Path.GetFileName(exePath);

            var updatePath = ConfigurationManager.AppSettings["UpdatePathFolder"];
            var packageId = ConfigurationManager.AppSettings["PackageID"];

            using (var mgr = new UpdateManager(updatePath, packageId, FrameworkVersion.Net45))
            {
                // Remove Desktop and Start Menu shortcuts
                mgr.RemoveShortcutsForExecutable(appName, DefaultLocations);
            }
        }
Beispiel #8
0
 public void ApplyAutorun()
 {
     using (var mgr = new UpdateManager(""))
     {
         try
         {
             if (Autorun)
                 mgr.CreateShortcutsForExecutable("Artemis.exe", ShortcutLocation.Startup, false);
             else
                 mgr.RemoveShortcutsForExecutable("Artemis.exe", ShortcutLocation.Startup);
         }
         catch (FileNotFoundException)
         {
             // Ignored, only happens when running from VS
         }
         catch (DirectoryNotFoundException)
         {
             // Ignored, only happens when running from VS
         }
         
     }
 }
        internal static void HandleSquirrelInstallEvent(string[] args)
        {
            #if __MonoCS__
            Debug.Fail("HandleSquirrelInstallEvent should not run on Linux!");	// and the code below doesn't compile on Linux
            return;
            #else
            bool firstTime = false;
            var updateUrlResult = LookupUrlOfSquirrelUpdate();
            // Should only be null if we're not online. Not sure how squirrel will handle that,
            // but at least one of these operations is responsible for setting up shortcuts to the program,
            // which we'd LIKE to work offline. Passing it a plausible url, even though it will presumably fail,
            // seems less likely to cause problems than passing null.
            if(string.IsNullOrEmpty(updateUrlResult.URL))
                updateUrlResult.URL = @"https://s3.amazonaws.com/bloomlibrary.org/squirrel";
            if (args[0] == "--squirrel-uninstall")
            {
                RemoveBloomRegistryEntries();
            }
            if (args[0] == "--squirrel-updated")
            {
                var props = new Dictionary<string, string>();
                if (args.Length > 1)
                    props["newVersion"] = args[1];
                props["channel"] = ApplicationUpdateSupport.ChannelName;
                Analytics.Track("Update Version", props);
            }
            string iconPath = null;
            if (args[0] == "--squirrel-install")
            {
                //Using an icon in the root folder fixes the problem of losing the shortcut icon when we
                //upgrade, lose the original, and eventually the windows explorer cache loses it.
                //There was another attempt at fixing this by finding all the shortcuts and updating them, but that didn't work in our testing and this seems simpler and more robust.
                //There may be some other reason for the old approach of pointing at the icon of the app itself (e.g. could be a different icon)?
                var exePath = Application.ExecutablePath;
                var rootAppDirectory = Path.GetDirectoryName(Path.GetDirectoryName(exePath));
                // directory that holds e.g. /3.6/Bloom.exe
                var versionIconPath = Path.ChangeExtension(exePath, "ico"); // where this installation has icon
                iconPath = Path.ChangeExtension(Path.Combine(rootAppDirectory, Path.GetFileName(exePath)), "ico");
                // where we will put a version-independent icon
                try
                {
                    if (RobustFile.Exists(versionIconPath))
                        RobustFile.Copy(versionIconPath, iconPath, true);
                }
                catch (Exception)
                {
                    // ignore...most likely some earlier version of the icon is locked somehow, fairly harmless.
                }
                // Normally this is done on every run of the program, but if we're doing a silent allUsers install,
                // this is our only time running with admin privileges so we can actually make the entries for all users.
                MakeBloomRegistryEntries(args);
            }
            switch (args[0])
            {
                // args[1] is version number
                case "--squirrel-install": // (first?) installed
                case "--squirrel-updated": // updated to specified version
                case "--squirrel-obsolete": // this version is no longer newest
                case "--squirrel-uninstall": // being uninstalled
                    using (var mgr = new UpdateManager(updateUrlResult.URL, Application.ProductName))
                    {
                        // WARNING, in most of these scenarios, the app exits at the end of HandleEvents;
                        // thus, the method call does not return and nothing can be done after it!
                        // We replace two of the usual calls in order to take control of where shortcuts are installed.
                        SquirrelAwareApp.HandleEvents(

                            onInitialInstall: v =>
                            {
                                mgr.CreateShortcutsForExecutable(Path.GetFileName(Assembly.GetEntryAssembly().Location),
                                    StartMenuLocations,
                                    false, // not just an update, since this is case initial install
                                    null, // can provide arguments to pass to Update.exe in shortcut, defaults are OK
                                    iconPath,
                                    SharedByAllUsers());
                                // Normally we can't do this in our quick silent run as part of install, because of the need to escalate
                                // privilege. But if we're being installed for all users we must already be running as admin.
                                // We don't need to do an extra restart of Bloom because this install-setup run of Bloom will finish
                                // right away anyway. We do this last because we've had some trouble (BL-3342) with timeouts
                                // if this install somehow ties up the CPU until Squirrel thinks Bloom is taking too long to do its
                                // install-only run.
                                if (SharedByAllUsers())
                                    FontInstaller.InstallFont("AndikaNewBasic", needsRestart: false);
                            },
                            onAppUpdate: v => mgr.CreateShortcutForThisExe(),
                            onAppUninstall: v => mgr.RemoveShortcutsForExecutable(Path.GetFileName(Assembly.GetEntryAssembly().Location), StartMenuLocations, SharedByAllUsers()),
                            onFirstRun: () => firstTime = true,
                            arguments: args);
                    }
                    break;
            }
            #endif
        }
Beispiel #10
0
 public static void UninstallEvent()
 {
     using (var mgr = new UpdateManager(@"https://releases.noelpush.com/", "NoelPush"))
     {
         mgr.RemoveShortcutsForExecutable("NoelPush.exe", ShortcutLocation.StartMenu);
         mgr.RemoveShortcutsForExecutable("NoelPush.exe", ShortcutLocation.Startup);
         mgr.RemoveUninstallerRegistryEntry();
         mgr.Dispose();
     }
 }