/// <summary> /// Creates a new Windows shortcut in the "Startup" menu. /// </summary> /// <param name="autoStart">Information about the shortcut to be created.</param> /// <param name="target">The target the shortcut shall point to.</param> /// <param name="handler">A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.</param> /// <param name="machineWide">Create the shortcut machine-wide instead of just for the current user.</param> public static void Create(AutoStart autoStart, FeedTarget target, ITaskHandler handler, bool machineWide) { #region Sanity checks if (autoStart == null) throw new ArgumentNullException("autoStart"); if (handler == null) throw new ArgumentNullException("handler"); #endregion string filePath = GetStartupPath(autoStart.Name, machineWide); Create(filePath, target.GetRunStub(autoStart.Command, handler)); }
/// <summary> /// Generates a command-line string for launching a <see cref="Store.Model.Capabilities.Verb"/>. /// </summary> /// <param name="target">The application being integrated.</param> /// <param name="verb">The verb to get to launch command for.</param> /// <param name="machineWide">Store the stub in a machine-wide directory instead of just for the current user.</param> /// <param name="handler">A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.</param> /// <exception cref="IOException">A problem occurs while writing to the filesystem.</exception> /// <exception cref="WebException">A problem occured while downloading additional data (such as icons).</exception> /// <exception cref="InvalidOperationException">Write access to the filesystem is not permitted.</exception> internal static string GetLaunchCommandLine(FeedTarget target, Store.Model.Capabilities.Verb verb, bool machineWide, ITaskHandler handler) { try { string launchCommand = "\"" + target.GetRunStub(verb.Command, handler, machineWide) + "\""; if (!string.IsNullOrEmpty(verb.Arguments)) launchCommand += " " + verb.Arguments; return launchCommand; } #region Error handling catch (InvalidOperationException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } #endregion }