public void Execute(object parameter) { var applicationTuple = _addAppViewModel.MainPageViewModel.Applications.FirstOrDefault(x => x.Config.Equals(_lastConfig)); var loaderConfig = IoC.Get <LoaderConfig>(); var shell = (IShellLink) new ShellLink(); shell.SetDescription($"Launch {applicationTuple?.Config.AppName} via Reloaded II"); shell.SetPath($"\"{loaderConfig.LauncherPath}\""); shell.SetArguments($"{Constants.ParameterLaunch} \"{_lastConfig.AppLocation}\""); shell.SetWorkingDirectory(Path.GetDirectoryName(loaderConfig.LauncherPath)); if (applicationTuple != null) { var hasIcon = ApplicationConfig.TryGetApplicationIcon(applicationTuple.ConfigPath, applicationTuple.Config, out var logoPath); if (hasIcon) { // Make path for icon. string newPath = Path.ChangeExtension(logoPath, ".ico"); // Convert to ICO and save. var bitmapImage = Imaging.BitmapFromUri(new Uri(logoPath, UriKind.Absolute)); var bitmap = Imaging.BitmapImageToBitmap(bitmapImage); var resizedBitmap = Imaging.ResizeImage(bitmap, Constants.IcoMaxWidth, Constants.IcoMaxHeight); using (var newIcon = Icon.FromHandle(resizedBitmap.GetHicon())) using (Stream newIconStream = new FileStream(newPath, FileMode.Create)) { newIcon.Save(newIconStream); } shell.SetIconLocation(newPath, 0); } else { shell.SetIconLocation(_lastConfig.AppLocation, 0); } } // Save the shortcut. var file = (IPersistFile)shell; var link = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{applicationTuple?.Config.AppName} via Reloaded II.lnk"); file.Save(link, false); var messageBox = new MessageBox(_xamlShortcutCreatedTitle.Get(), $"{_xamlShortcutCreatedMessage.Get()} {link}"); messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen; messageBox.ShowDialog(); }