static void Main() { SquirrelAwareApp.HandleEvents( OnInitialInstall, OnAppUpdate, onAppUninstall: OnAppUninstall, onFirstRun: OnFirstRun); AppHost = new AppHost(); Cef.EnableHighDPISupport(); Cef.Initialize(new CefSettings()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { AppHost.Init().Start("http://*:2337/"); "ServiceStack SelfHost listening at {0} ".Fmt(HostUrl).Print(); Form = new FormMain(); } catch (Exception e) { "Listening to existing service at {0}".Print(HostUrl); Form = new FormMain(startRight: true); } Form.Disposed += (sender, args) => AppUpdater.Dispose(); Application.Run(Form); }
public static async Task StartupUpdateCheck(SplashScreenWindow splashScreenWindow) { try { bool updated; using (var mgr = await UpdateManager.GitHubUpdateManager("https://github.com/Epix37/HDT-Releases", prerelease: Config.Instance.CheckForBetaUpdates)) { SquirrelAwareApp.HandleEvents( v => mgr.CreateShortcutForThisExe(), v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe() ); updated = await SquirrelUpdate(splashScreenWindow, mgr); } if (updated) { if (splashScreenWindow.SkipWasPressed) { StatusBar.Visibility = Visibility.Visible; } else { UpdateManager.RestartApp(); } } } catch (Exception ex) { Log.Error(ex); } }
static void HandleSquirrel() { /* * var isUninstalling = System.Environment.GetCommandLineArgs().Any(x => x.Contains("uninstall")); * using (var logger = new SetupLogLogger(isUninstalling) { Level = Splat.LogLevel.Info }) { * Splat.Locator.CurrentMutable.Register(() => logger, typeof (Splat.ILogger)); */ using (var mgr = SquirrelUpdater.GetUpdateManager()) { // Note, in most of these scenarios, the app exits after this method // completes! SquirrelAwareApp.HandleEvents(v => InitialInstall(mgr), v => Update(mgr), onAppUninstall: v => { mgr.RemoveShortcutForThisExe(); if (MessageBox.Show( "Do you wish to keep the Configuration data, WARNING: Choosing 'No' cannot be undone!", "Keep the configuration data?", MessageBoxButton.YesNo) == MessageBoxResult.No) { UninstallConfigurationData(); } mgr.RemoveUninstallerRegistryEntry(); } //, //onFirstRun: () => ShowTheWelcomeWizard = true ); } RunVcRedist(); }
public static async Task StartupUpdateCheck(SplashScreenWindow splashScreenWindow) { try { Log.Info("Checking for updates"); bool updated; using (var mgr = await UpdateManager.GitHubUpdateManager(await GetReleaseUrl("live"), prerelease: Config.Instance.CheckForBetaUpdates)) { SquirrelAwareApp.HandleEvents( v => mgr.CreateShortcutForThisExe(), v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe(), onFirstRun: CleanUpInstallerFile ); updated = await SquirrelUpdate(splashScreenWindow, mgr); } if (updated) { if (splashScreenWindow.SkipUpdate) { Log.Info("Update complete, showing update bar"); StatusBar.Visibility = Visibility.Visible; } else { Log.Info("Update complete, restarting"); UpdateManager.RestartApp(); } } } catch (Exception ex) { Log.Error(ex); } }
protected override void OnStartup(StartupEventArgs e) { // allow only one instance of color picker bool createdNew; _instanceMutex = new Mutex(true, @"Global\ControlPanel", out createdNew); if (!createdNew) { _instanceMutex = null; Application.Current.Shutdown(); return; } using (var mgr = new UpdateManager("")) { // Note, in most of these scenarios, the app exits after this method // completes! SquirrelAwareApp.HandleEvents( onInitialInstall: v => mgr.CreateShortcutForThisExe(), onAppUpdate: v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe(), onFirstRun: () => ShowWelcome()); } base.OnStartup(e); }
public void ConfigureAppInstallation() { using (var UpdateManager = new UpdateManager(UpdatePath)) { SquirrelAwareApp.HandleEvents( onInitialInstall: v => { UpdateManager.KillAllExecutablesBelongingToPackage(); UpdateManager.RemoveShortcutForThisExe(); UpdateManager.KillAllExecutablesBelongingToPackage(); }, onAppUpdate: v => { UpdateManager.RemoveShortcutForThisExe(); }, onAppUninstall: async v => { UpdateManager.RemoveShortcutForThisExe(); await UpdateManager.FullUninstall(); //FileHandler.CleanUpReplicationDirectory(); }, onFirstRun: () => { UpdateManager.KillAllExecutablesBelongingToPackage(); UpdateManager.RemoveShortcutForThisExe(); UpdateManager.KillAllExecutablesBelongingToPackage(); } ); } }
private static void Main() { // Method 1 Task.Run(async() => { //using (var mgr = new UpdateManager(UpdatePath, "Pomodoro")) using (var mgr = new UpdateManager(Data.Constants.UpdatePath)) { await mgr.UpdateApp(); } }); // Method 2.A SquirrelAwareApp.HandleEvents( onAppUpdate: UpdaterForm.OnAppUpdate, onAppUninstall: UpdaterForm.OnAppUninstall, onInitialInstall: UpdaterForm.OnInitialInstall); // Method 2.B SquirrelAwareApp.HandleEvents(ver => { var mggr = default(UpdateManager); mggr.CreateShortcutsForExecutable("exeName", ShortcutLocation.Desktop, true); }); Application.Run(new PomodoroTimer()); }
/// <summary> /// Initializes a new instance of the App class. /// </summary> static App() { Logger.Info( "Popcorn starting..."); var watchStart = Stopwatch.StartNew(); Directory.CreateDirectory(Constants.Logging); DispatcherHelper.Initialize(); LocalizeDictionary.Instance.SetCurrentThreadCulture = true; watchStart.Stop(); var elapsedStartMs = watchStart.ElapsedMilliseconds; Logger.Info( $"Popcorn started in {elapsedStartMs} milliseconds."); #if !DEBUG SquirrelAwareApp.HandleEvents( onInitialInstall: OnInitialInstall, onAppUpdate: OnAppUpdate, onAppUninstall: OnAppUninstall, onFirstRun: OnFirstRun); #endif }
/// <summary> /// Initializes a new instance of the App class. /// </summary> static App() { WatchStart = Stopwatch.StartNew(); var config = new LoggingConfiguration(); var target = new ApplicationInsightsTarget { InstrumentationKey = Constants.AiKey }; var rule = new LoggingRule("*", LogLevel.Trace, target); config.LoggingRules.Add(rule); LogManager.Configuration = config; Logger.Info( "Popcorn starting..."); DispatcherHelper.Initialize(); LocalizeDictionary.Instance.SetCurrentThreadCulture = true; BlobCache.ApplicationName = "Popcorn"; try { SquirrelAwareApp.HandleEvents( onFirstRun: () => { // TODO: Must complete welcome.md page before activate this feature //_firstRun = true; }); } catch (Exception ex) { Logger.Error(ex); } }
private static void Main(string[] args) { #if DEBUG //SetStartup(true); // For testing //UpdateApp(); // For testing #else // Customize Squirrel update events (this also prevents shortcuts from being created as happens in the default implementation) using (var updateManager = new UpdateManager("")) { SquirrelAwareApp.HandleEvents( onInitialInstall: v => SetStartup(false), onAppUpdate: v => SetStartup(false), onAppUninstall: v => SetStartup(true), onFirstRun: () => MessageBox.Show(ON_FIRST_RUN_DESCRIPTION, ON_FIRST_RUN_TITLE)); } UpdateApp(); #endif // Read custom BIG_TASKBAR_RES setting from App.config try { BIG_TASKBAR_RES = Int32.Parse(ConfigurationManager.AppSettings["BIG_TASKBAR_RES"]); } catch (Exception) { } SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; // We are never detaching the event handler SystemEvents_DisplaySettingsChanged(null, null); //ToggleTaskbarSize(); // For testing Application.Run(); // Blocking. This prevents the application from closing. }
static void Main(string[] args) { try { //This can be used to inform about update status SquirrelAwareApp.HandleEvents(onAppUpdate: v => Console.WriteLine($"updating to {v}")); Console.WriteLine("Current version is : " + Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine("Connecting to IoT Hub"); Client = DeviceClient.CreateFromConnectionString(deviceConnectionString, TransportType.Mqtt); // Set callback for "updateApp" method Client.SetMethodHandlerAsync("updateApp", updateAppMethod, null).Wait(); Console.WriteLine("Waiting for direct method call\n Press enter to exit."); Console.ReadLine(); Console.WriteLine("Exiting..."); // Remove the "updateApp" handler Client.SetMethodHandlerAsync("updateApp", null, null).Wait(); Client.CloseAsync().Wait(); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); } }
static void Main() { SquirrelAwareApp.HandleEvents(onAppUpdate: FormMain.OnAppUpdate, onAppUninstall: FormMain.OnAppUninstall, onInitialInstall: FormMain.OnInitialInstall); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); }
public App() { try { using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/Henry-YSLin/QuickDictionary").Result) { // Note, in most of these scenarios, the app exits after this method // completes! SquirrelAwareApp.HandleEvents( onInitialInstall: v => mgr.CreateShortcutForThisExe(), onAppUpdate: v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => { mgr.RemoveShortcutForThisExe(); mgr.RemoveUninstallerRegistryEntry(); }, onFirstRun: () => { }); } } catch (Exception) { } var settings = new CefSettings(); settings.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "QuickDictionary\\cache"); settings.PersistUserPreferences = true; settings.PersistSessionCookies = true; settings.UserAgent = "Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36"; Cef.Initialize(settings); }
static void Main() { using (var mgr = new UpdateManager("https://github.com/Ficss/ReportesPeajesCentralizado")) { // Note, in most of these scenarios, the app exits after this method // completes! SquirrelAwareApp.HandleEvents( onInitialInstall: v => mgr.CreateShortcutForThisExe(), onAppUpdate: v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe(), onFirstRun: () => ShowTheWelcomeWizard = true); } string guid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString(); using (Mutex mutex = new Mutex(false, "Global\\" + guid)) { if (!mutex.WaitOne(0, false)) { return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Padre()); } }
private void App_OnStartup(object sender, StartupEventArgs e) { if (e.Args.Length > 0) { using (var mgr = new UpdateManager("http://zizit.lt")) { // Note, in most of these scenarios, the app exits after this method // completes! SquirrelAwareApp.HandleEvents( onInitialInstall: v => { mgr.CreateShortcutForThisExe(); Shutdown(); }, onAppUpdate: v => { mgr.CreateShortcutForThisExe(); Shutdown(); }, onAppUninstall: v => { mgr.RemoveShortcutForThisExe(); Shutdown(); }, onFirstRun: () => { MessageBox.Show("Success", "Installation successful", MessageBoxButton.OK); Shutdown(); }); } } }
public async Task Run(bool downloadPrerelease = false) { // GitHub requires TLS 1.2, we need to hardcode this for Windows 7 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; using (var updateManager = await UpdateManager.GitHubUpdateManager(repoUrl: RepoUrl, applicationName: "XIVLauncher", prerelease: downloadPrerelease)) { SquirrelAwareApp.HandleEvents( onInitialInstall: v => updateManager.CreateShortcutForThisExe(), onAppUpdate: v => updateManager.CreateShortcutForThisExe(), onAppUninstall: v => updateManager.RemoveShortcutForThisExe()); var downloadedRelease = await updateManager.UpdateApp(); if (downloadedRelease != null) { UpdateManager.RestartApp(); } else { OnUpdateCheckFinished?.Invoke(this, null); } } // Reset security protocol after updating ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault; }
/// <summary> /// Initializes a new instance of the App class. /// </summary> static App() { try { // Dirty fix for https://github.com/Microsoft/ApplicationInsights-dotnet/issues/638 foreach (var file in SnapshotCollectorFiles) { File.SetLastWriteTimeUtc( $@"{ Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName }\SnapshotCollectorFiles\{file}", DateTime.MaxValue); } } catch (Exception) { } WatchStart = Stopwatch.StartNew(); Logger.Info( "Popcorn starting..."); DispatcherHelper.Initialize(); LocalizeDictionary.Instance.SetCurrentThreadCulture = true; BlobCache.ApplicationName = "Popcorn"; try { SquirrelAwareApp.HandleEvents( onInitialInstall: OnInitialInstall, onAppUpdate: OnAppUpdate, onAppUninstall: OnAppUninstall, onFirstRun: OnFirstRun); } catch (Exception ex) { Logger.Error(ex); } }
protected override void OnStartup(StartupEventArgs e) { // allow only one instance of file explorer gallery bool createdNew; _instanceMutex = new Mutex(true, @"Global\FileExplorerGallery", out createdNew); if (!createdNew) { _instanceMutex = null; Current.Shutdown(); return; } using (var mgr = new UpdateManager("")) { // Note, in most of these scenarios, the app exits after this method // completes! SquirrelAwareApp.HandleEvents( onInitialInstall: v => mgr.CreateShortcutForThisExe(), onAppUpdate: v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe(), onFirstRun: () => ShowWelcome()); } base.OnStartup(e); Bootstrapper.InitializeContainer(this); MigrateUserSettings(); SetupTrayIcon(); KeyboardMonitor.Start(); Current.MainWindow = null; }
public void HandleSquirrelEvents() { if (!Program.UseSquirrel) { return; } SquirrelAwareApp.HandleEvents( onInitialInstall: v => { Log.Information("Squirrel: On initial install: " + v); _updateManager.CreateShortcutForThisExe(); EnableRunAtStartUpAction.EnableRunAtStartUp(); }, onAppUpdate: v => { File.WriteAllText(CatapultPaths.NewVersionPath, v.ToString()); Log.Information("Squirrel: On app update: " + v); _updateManager.CreateShortcutForThisExe(); EnableRunAtStartUpAction.UpdateRunAtStartUp(); }, onAppUninstall: v => { Log.Information("Squirrel: On app uninstall: " + v); _updateManager.RemoveShortcutForThisExe(); DisableRunAtStartUpAction.RemoveRunAtStartUp(); }, onAppObsoleted: v => { Log.Information("Squirrel: On app obsoleted: " + v); }, onFirstRun: () => { Log.Information("Squirrel: On first run."); }); }
public static async Task StartupUpdateCheck() { try { Log.Info("Checking for updates"); bool updated; using (var mgr = await GetUpdateManager()) { SquirrelAwareApp.HandleEvents( v => { mgr.CreateShortcutForThisExe(); }, onAppUninstall: v => { mgr.RemoveShortcutForThisExe(); } ); updated = await SquirrelUpdate(mgr); } if (updated) { Log.Info("Update complete, restarting"); UpdateManager.RestartApp(); } } catch (Exception ex) { Log.Error(ex); } }
static void Main() { AppDomain.CurrentDomain.UnhandledException += AllUnhandledExceptions; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.File("./logs/log.txt", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 10) .CreateLogger(); using (var mgr = new UpdateManager("https://github.com/ahmedayman4a/Linkedin-Learning-Courses-Downloader.UpdateManager")) { SquirrelAwareApp.HandleEvents( onInitialInstall: v => { mgr.CreateShortcutForThisExe(); }, onAppUpdate: v => { mgr.CreateShortcutForThisExe(); }, onAppUninstall: v => mgr.RemoveShortcutForThisExe()); } Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); if (!File.Exists("IconAddedToRegistry")) { AddIconToRegistry(); File.Create("IconAddedToRegistry"); } Config.Restore(); Application.Run(new MainForm()); }
static void Main() { AppHost = new AppHost(); SquirrelAwareApp.HandleEvents( OnInitialInstall, OnAppUpdate, onAppUninstall: OnAppUninstall, onFirstRun: OnFirstRun); Cef.EnableHighDPISupport(); var cacheFolder = Path.Combine(Path.GetTempPath(), "cefsharp-cache"); Cef.Initialize(new CefSettings { CachePath = cacheFolder }); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppHost.Init().Start("http://*:2337/"); "ServiceStack SelfHost listening at {0} ".Fmt(HostUrl).Print(); Form = new FormMain(); Form.Disposed += (sender, args) => AppUpdater.Dispose(); Application.Run(Form); }
public static async Task RunUpdater() { try { Bot.Log("Check for updates..."); bool updated; using (var mgr = await GetUpdateManager()) { SquirrelAwareApp.HandleEvents( onInitialInstall: v => mgr.CreateShortcutForThisExe(), onAppUpdate: v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe()); updated = await SquirrelUpdate(mgr); } if (updated) { Bot.Log("Update complete, restarting"); UpdateManager.RestartApp(); } } catch { Bot.Log("Failed to update!"); } }
private void Application_Startup(object sender, StartupEventArgs e) { var updateManager = new UpdateManager(Constants.PackagePath); SquirrelAwareApp.HandleEvents( onInitialInstall: v => { updateManager.CreateShortcutForThisExe(); updateManager.CreateUninstallerRegistryEntry(); }, onAppUpdate: v => { //updateManager.RemoveShortcutForThisExe(); updateManager.CreateShortcutForThisExe(); //updateManager.RemoveUninstallerRegistryEntry(); updateManager.CreateUninstallerRegistryEntry(); //UpdateManager.RestartApp(); }, onAppUninstall: v => { updateManager.RemoveShortcutForThisExe(); updateManager.RemoveUninstallerRegistryEntry(); }); //onFirstRun: () => ShowTheWelcomeWizard = true); // Create the startup window MainWindow wnd = new MainWindow(); // Do stuff here, e.g. to the window wnd.Title = "Squirrel Demo"; // Show the window wnd.Show(); }
/// <summary> /// Does stuff related to Squirrel.Windows, such as beginning a self-update in the background. /// Starts the self-update process, updating the application to the newest version in the background. /// </summary> private static async void DoSquirrelStuff() { try { // Use regular update manager in case there is no found commit on Github using (var tempUpdateManager = new UpdateManager("")) { // Handle application installs, uninstalls. SquirrelAwareApp.HandleEvents( onInitialInstall: v => tempUpdateManager.CreateShortcutForThisExe(), onAppUpdate: v => tempUpdateManager.CreateShortcutForThisExe(), onAppUninstall: v => tempUpdateManager.RemoveShortcutForThisExe() ); } // Update from Github using (var updateManager = await UpdateManager.GitHubUpdateManager("https://github.com/sewer56lol/Reloaded-Mod-Loader", prerelease: true)) { // Check for release info. UpdateInfo update = await updateManager.CheckForUpdate(false); // Update if there are any releases. if (update.ReleasesToApply.Count > 0) { await updateManager.UpdateApp(); } } } catch (Exception) { /* ¯\_(ツ)_/¯ */ } }
internal static void Main(String[] arguments) { #pragma warning disable CA1416 // Validate platform compatibility SquirrelAwareApp.HandleEvents(); #pragma warning restore CA1416 // Validate platform compatibility Parser.Default.ParseArguments <Options>(arguments).WithParsed(Run); }
public static async Task StartupUpdateCheck(SplashScreenWindow splashScreenWindow) { try { Log.Info("Checking for updates"); bool updated; using (var mgr = await GetUpdateManager()) { RegistryHelper.SetExecutablePath(Path.Combine(mgr.RootAppDirectory, "Update.exe")); RegistryHelper.SetExecutableArgs("--processStart \"HearthstoneDeckTracker.exe\""); SquirrelAwareApp.HandleEvents( v => { mgr.CreateShortcutForThisExe(); if (Config.Instance.StartWithWindows) { RegistryHelper.SetRunKey(); } }, v => { mgr.CreateShortcutForThisExe(); if (Config.Instance.StartWithWindows) { RegistryHelper.SetRunKey(); } }, onAppUninstall: v => { mgr.RemoveShortcutForThisExe(); if (Config.Instance.StartWithWindows) { RegistryHelper.DeleteRunKey(); } }, onFirstRun: CleanUpInstallerFile ); updated = await SquirrelUpdate(mgr, splashScreenWindow); } if (updated) { if (splashScreenWindow.SkipUpdate) { Log.Info("Update complete, showing update bar"); StatusBar.Visibility = Visibility.Visible; } else { Log.Info("Update complete, restarting"); UpdateManager.RestartApp(); } } } catch (Exception ex) { Log.Error(ex); } }
public static void Setup() { SquirrelAwareApp.HandleEvents( onInitialInstall: v => CopyFiles(), onAppUpdate: v => CopyFiles(), onAppUninstall: v => DeleteFiles(), onFirstRun: () => { } ); }
protected override void OnStartup(StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += App.CurrentDomain_UnhandledException; try { NativeMethods.SetCurrentProcessExplicitAppUserModelID("com.squirrel.XIVHunt.XIV-Hunt"); } catch { } if (ApplicationRunningHelper.AlreadyRunning()) { Thread.Sleep(2000); if (ApplicationRunningHelper.AlreadyRunning()) { return; } } bool isFirstInstall = App.RestoreSettings(); if (isFirstInstall && App.IsSquirrelInstall()) { try { Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; new LanguageSelector().ShowDialog(); } catch (Exception) { } } if (App.IsSquirrelInstall()) { SquirrelAwareApp.HandleEvents(null, delegate(Version v) { Updater.OnAppUpdate(); }, null, null, new Action(Updater.OnFirstRun), null); using (CancellationTokenSource cts = new CancellationTokenSource()) { Task task = Updater.Create(cts.Token); task.Start(); task.Wait(); } } base.MainWindow = new Window1(); Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; base.MainWindow.Show(); base.OnStartup(e); if (isFirstInstall && App.IsSquirrelInstall()) { Task.Run(async delegate() { await Task.Delay(1000).ConfigureAwait(false); App.TryShowInstalledShortcutInfoToast(); }); } }
internal void OnInstallationAndUpdate() { // Note, in most of these scenarios, the app exits after this method completes! SquirrelAwareApp.HandleEvents( onInitialInstall: v => this.actions.SetOsPath(), onAppUpdate: v => this.actions.SetOsPath(), onAppUninstall: v => this.actions.RemoveOsPath(), onFirstRun: () => { }); }