protected void CreateShortcut(ReleaseList remoteRelease) { if (string.IsNullOrEmpty(remoteRelease.ShortcutIcon) || remoteRelease.ShortcutIcon.Trim().Length == 0) { return; } string iconLocation = AppDomain.CurrentDomain.BaseDirectory + remoteRelease.ShortcutIcon; string appName = remoteRelease.AppName; foreach (char invalidChar in Path.GetInvalidFileNameChars()) { appName = appName.Replace(invalidChar, '_'); } string shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" + appName + ".lnk"; if (File.Exists(shortcutPath)) { return; } var creator = new ShortcutCreator( appName, AppDomain.CurrentDomain.BaseDirectory + Constants.UpdaterExeName, iconLocation, remoteRelease.Company); creator.CreateOnDesktop(); creator.CreateOnStartMenu(); }
void CreateShortcut(IAbsoluteDirectoryPath destinationPath, IAbsoluteFilePath installExe) { ShortcutCreator.CreateShortcut(new ShortcutInfo(destinationPath, "Play withSIX", installExe) { WorkingDirectory = InstallPath, Description = "Play withSIX" }); }
static int Main(string[] args) { try { // Create necessary shortcuts if (string.Equals("True", ConfigurationManager.AppSettings["ShowToast"])) { ShortcutCreator.TryCreateMenuShortcut(APP_ID, "WallpaperX"); } if (string.Equals("True", ConfigurationManager.AppSettings["StartWithWindows"])) { ShortcutCreator.TryCreateStartupShortcut(APP_ID, "WallpaperX"); } } catch { Console.WriteLine("Cannot install Start Menu shortcut."); return(1); } IPictureSource pictureSource = null; try { pictureSource = PictureSourceFactory.Get(ConfigurationManager.AppSettings["PictureSource"]); } catch { Console.WriteLine("PictureSource not configured properly."); return(1); } ChangeStrategy.ChangeStrategy changeStrategy = null; try { changeStrategy = ChangeStrategyFactory.Get(ConfigurationManager.AppSettings["ChangeStrategy"], pictureSource); } catch { Console.WriteLine("ChangeStrategy not configured properly."); return(1); } Thread strategyThread = new Thread(changeStrategy.RunLogic); strategyThread.Start(); strategyThread.Join(); return(0); }
/// <summary> /// 设置页面 /// </summary> public WindowSet() { InitializeComponent(); //移动 MouseLeftButtonDown += (sender, e) => { DragMove(); }; //关闭 BtnClose.Click += (sender, e) => { Close(); }; //确认 BtnCheck.Click += (sender, e) => { foreach (WindowNotepad notepad in NotepadManage.WindowList) { notepad.ShowInTaskbar = SystemSetting.ShowInTaskbar; if (ChkNotepadAll.IsChecked == true || notepad.Equals(WindowNotepad)) { notepad.Opacity = SliderOpacity.Value; notepad.WindowSettings.TitleBottomHeight = SliderTitleBottom.Value; notepad.TxtTitleBottom.FontSize = SliderTitleBottomFontSize.Value; if (notepad.Top < 0) { notepad.GridTitleBottom.Height = SliderTitleBottom.Value; while ((Int64)notepad.Top != (Int64)(-notepad.ActualHeight + notepad.WindowSettings.TitleBottomHeight)) { notepad.Top += notepad.Top >= -notepad.ActualHeight + notepad.WindowSettings.TitleBottomHeight ? -1 : 1; } } } } //设置主窗体 SystemCommon.WindowMain.ShowInTaskbar = !SystemSetting.ShowInTaskbar; //非调试模式 if (!System.Diagnostics.Debugger.IsAttached) { try { if (Boot == true) { //开机启动 ShortcutCreator.CreateShortcutOnDesktop(SystemCommon.SystemName); if (!AutoBoot.SetAutoBootStatu1(true, SystemCommon.SystemName)) { AutoBoot.SetAutoBootStatu(true, SystemCommon.SystemName); } } else { //取消开机启动 AutoBoot.SetAutoBootStatu1(false, SystemCommon.SystemName); AutoBoot.SetAutoBootStatu(false, SystemCommon.SystemName); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } Close(); }; }
private void Init() { context.InstInfo.InstallPath = context.ConvertPath(context.InstInfo.InstallPath); context.Files.ForEach(x => x.Path = context.ConvertPath(x.Key)); context.UninstallData = new UninstallData() { UninstallKey = context.AppInfo.AppName, InstallPath = context.InstInfo.InstallPath, AppName = context.AppInfo.FullName, Shortcuts = new List <string>() }; var index = 0; var fileExtractor = new FileExtractor(); fileExtractor.SetContext(context, process); commands.Add(new Cmd() { Index = index++, Command = fileExtractor }); var shortcutCreator = new ShortcutCreator(); shortcutCreator.SetContext(context, process); commands.Add(new Cmd() { Index = index++, Command = shortcutCreator }); foreach (var cmdInfo in context.Commands) { cmdInfo.ArgList = cmdInfo.ArgList?.Select(x => context.ConvertPath(context.ConvertVars(x))).ToArray() ?? new string[0]; var cmd = BaseCommand.GetCommand(cmdInfo.Target); if (cmd != null) { cmd.SetContext(context, process, cmdInfo.Name, cmdInfo.ArgList); commands.Add(new Cmd() { Index = index++, Command = cmd }); } else { commands.Add(new Cmd() { Index = index++, CmdInfo = cmdInfo }); } } var uninsCreator = new UninsCreator(); uninsCreator.SetContext(context, process); commands.Add(new Cmd() { Index = index++, Command = uninsCreator }); var registerEditor = new RegisterEditor(); registerEditor.SetContext(context, process); commands.Add(new Cmd() { Index = index++, Command = registerEditor }); process?.SetMaxValue(GetProcessValue(), ValueMin); }
private void ShortcutButton_Clicked(object sender, RoutedEventArgs e) { ShortcutCreator.CreateShortcutOnDesktop("UbiGamesBackupToolX", this.GetType().Assembly.Location); }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.White; PackageCore packageCore = new PackageCore(); Side(); string AppFolder = "./UAP"; switch (SystemEnvironment.currentSystem) { case SystemType.Windows: AppFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UAP"); break; case SystemType.Linux: AppFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "UAP"); break; case SystemType.MacOS: break; default: break; } BasicFunctions.Init(); Host.ReadLine = Console.ReadLine; Host.WriteLine = Console.WriteLine; Host.Write = Console.Write; Host.ResetColor = Console.ResetColor; Host.SetForeground = (ConsoleColor c) => { Console.ForegroundColor = c; }; for (int i = 0; i < args.Length; i++) { switch (args[i].ToUpper()) { case "INSTALL": i++; try { var package = packageCore.LoadPackage(args[i]); var pkginfo = package.GetInfomation(); Console.WriteLine("Install from:" + args[i]); if (package is ManifestPackage) { Console.Write("Package Type:"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("ManifestPackage"); Console.ForegroundColor = ConsoleColor.White; } double p = 0; //Console.ResetColor(); var result = package.Install(ref p); if (result.Status != UniversalAutomaticPackage.PackageSystem.InstallationStatus.Fail) { DirectoryInfo AppsFolder = new DirectoryInfo(AppFolder); //package var pkg = Path.Combine(AppsFolder.FullName, pkginfo.PackageID.ToString()); Console.WriteLine("Moveing from TemporaryFolder to assigned folder"); BasicFunctions.CopyFolder(result.BinFolder.FullName, pkg); Console.WriteLine("Creating shortcut."); ShortcutCreator.Create(Path.Combine(pkg, package.MainExecutable.fileName), package.MainExecutable.targetDisplayName); Console.WriteLine("Registering Package."); InstalledPackage.RegisterPackage(pkginfo.FriendlyName, pkg); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Completed."); Console.ForegroundColor = ConsoleColor.White; //package.MainExecutable; //Directory.Move(result.BinFolder.FullName, pkg); } else { Console.WriteLine("Failed."); Console.WriteLine("" + result.DetailedMessage); } } catch (Exception e) { Console.WriteLine("Error:" + e.Message); } break; case "REMOVE": { } break; case "VERSION": { Console.Write("UAP,Core:"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(PackageCore.CoreVersion.ToString()); Console.ForegroundColor = ConsoleColor.White; Console.Write("UAP,CLI:"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(CLIVerion.ToString()); Console.ForegroundColor = ConsoleColor.White; } break; case "INIT": if (!Directory.Exists(AppFolder)) { Directory.CreateDirectory(AppFolder); } break; default: break; } } if (args.Length == 0) { ShowHelpContent(); } }