public void CreateShortcut(Game game) { try { var path = Environment.ExpandEnvironmentVariables(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), Paths.GetSafeFilename(game.Name) + ".lnk")); string icon = string.Empty; if (!string.IsNullOrEmpty(game.Icon) && Path.GetExtension(game.Icon) == ".ico") { icon = Database.GetFullFilePath(game.Icon); } else if (game.PlayAction?.Type == GameActionType.File) { icon = game.GetRawExecutablePath(); } var args = new CmdLineOptions() { Start = game.Id.ToString() }.ToString(); Programs.CreateShortcut(PlaynitePaths.DesktopExecutablePath, args, icon, path); } catch (Exception exc) when(!PlayniteEnvironment.ThrowAllErrors) { logger.Error(exc, "Failed to create shortcut: "); Dialogs.ShowMessage( string.Format(resources.GetString("LOCGameShortcutError"), exc.Message), resources.GetString("LOCGameError"), MessageBoxButton.OK, MessageBoxImage.Error); } }
public static void SetBootupStateRegistration(bool runOnBootup) { var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); var shortcutPath = Path.Combine(startupPath, "Playnite.lnk"); if (runOnBootup) { var args = new CmdLineOptions() { HideSplashScreen = true }.ToString(); if (File.Exists(shortcutPath)) { var existLnk = Programs.GetLnkShortcutData(shortcutPath); if (existLnk.Path == PlaynitePaths.DesktopExecutablePath && existLnk.Arguments == args) { return; } } FileSystem.DeleteFile(shortcutPath); Programs.CreateShortcut(PlaynitePaths.DesktopExecutablePath, args, "", shortcutPath); } else { FileSystem.DeleteFile(shortcutPath); } }
public static void SetBootupStateRegistration(bool runOnBootup) { var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); var shortcutPath = Path.Combine(startupPath, "Playnite.lnk"); if (runOnBootup) { FileSystem.DeleteFile(shortcutPath); Programs.CreateShortcut(PlaynitePaths.DesktopExecutablePath, "", "", shortcutPath); } else { FileSystem.DeleteFile(shortcutPath); } }
public static void SetBootupStateRegistration(bool runOnBootup) { var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); var shortcutPath = Path.Combine(startupPath, "Playnite.lnk"); if (runOnBootup) { FileSystem.DeleteFile(shortcutPath); var hideSplashScreenOption = new CmdLineOptions() { HideSplashScreen = true }; Programs.CreateShortcut(PlaynitePaths.DesktopExecutablePath, hideSplashScreenOption.ToString(), "", shortcutPath); } else { FileSystem.DeleteFile(shortcutPath); } }