/// <summary> /// Create a shortcut in the current user's start menu /// Only do current user to avoid need for admin elevation /// </summary> /// <param name="targetExe"></param> protected InstallationResult CreateShortcuts(string targetExe) { // get path to all users start menu var startMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3"); if (!Directory.Exists(startMenu)) { Directory.CreateDirectory(startMenu); } Trace.TraceInformation("Creating start menu shortcut {0}", Path.Combine(startMenu, FriendlyName + ".lnk")); var product = new ShellShortcut(Path.Combine(startMenu, FriendlyName + ".lnk")) { Path = targetExe, Description = "Run " + FriendlyName }; product.Save(); if (PackageName == "MBServer") { var path = Path.Combine(startMenu, "MB Dashboard.lnk"); Trace.TraceInformation("Creating dashboard shortcut {0}", path); var dashboard = new ShellShortcut(path) { Path = @"http://localhost:8096/mediabrowser/dashboard/dashboard.html", Description = "Open the Media Browser Server Dashboard (configuration)" }; dashboard.Save(); } return(CreateUninstaller(Path.Combine(Path.GetDirectoryName(targetExe) ?? "", "MediaBrowser.Uninstaller.exe") + " " + (PackageName == "MBServer" ? "server" : "mbt"), targetExe)); }
private void buttonShortcut_Click(object sender, EventArgs e) { if (!_MacroNameValid) { return; } string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string macroName = MacroName; string shortcutPath = Path.Combine(desktopPath, String.Format("Macro - {0}.lnk", macroName)); ShellShortcut shortcut = new ShellShortcut(shortcutPath); string translatorFolder = SystemRegistry.GetInstallFolder(); if (translatorFolder == null) { translatorFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } shortcut.Arguments = String.Format("-MACRO \"{0}\"", macroName); shortcut.Description = "Launch Macro: " + macroName; shortcut.Path = Path.Combine(translatorFolder, "Translator.exe"); shortcut.WorkingDirectory = translatorFolder; //shortcut.WindowStyle = ProcessWindowStyle.Normal; shortcut.Save(); }
protected override void DoExecute() { if (string.IsNullOrEmpty(_versionDeploymentDirPath.Value)) { throw new DeploymentTaskException("_versionDeploymentDirPath not created."); } // check if file exists string targetPath = Path.Combine(_versionDeploymentDirPath.Value, _terminalAppExeName); if (!File.Exists(targetPath)) { throw new DeploymentTaskException(string.Format("Target file {0} does not exist when creating shortcut", targetPath)); } string shortcutPath = Path.Combine(_terminalAppsShortcutFolder, _projectName + ".lnk"); using (var shortcut = new ShellShortcut(shortcutPath)) { shortcut.Path = targetPath; shortcut.WorkingDirectory = Path.GetDirectoryName(_versionDeploymentDirPath.Value); shortcut.Description = _projectName; shortcut.Save(); } }
public virtual bool InstallSentTo() { string path = GetSendToPath(); ShellShortcut shortCut = new ShellShortcut(path); shortCut.Arguments = string.Format("/c:{0}", this.CommandName); shortCut.Description = this.Description; shortCut.Path = Application.ExecutablePath; shortCut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath); shortCut.IconPath = this.IconPath; shortCut.IconIndex = this.IconIndex; shortCut.Save(); return true; }
private static void SetSendToAssociation(String destinationPath, String culture) { String sendToDir = Environment.GetFolderPath(Environment.SpecialFolder.SendTo); ShellShortcut shortcut = new ShellShortcut(Path.Combine(sendToDir, "DtPad.lnk")) { Path = Path.Combine(destinationPath, "DtPad.exe"), WorkingDirectory = destinationPath, Description = LanguageUtil.GetCurrentLanguageString("LinkLaunchDtPad", className, culture), IconPath = Path.Combine(destinationPath, "Icons\\DtPad.ico") }; shortcut.Save(); }
internal static void SetSendToLink() { String sendToDir = Environment.GetFolderPath(Environment.SpecialFolder.SendTo); String destinationPath = ConstantUtil.ApplicationExecutionPath(); ShellShortcut shortcut = new ShellShortcut(Path.Combine(sendToDir, "DtPad.lnk")) { Path = Path.Combine(destinationPath, "DtPad.exe"), WorkingDirectory = destinationPath, Description = LanguageUtil.GetCurrentLanguageString("LinkLaunchDtPad", className), IconPath = Path.Combine(destinationPath, "Icons\\DtPad.ico") }; shortcut.Save(); }
protected void btnSave_Click(object sender, EventArgs e) { m_Shortcut.Path = txtTarget.Text; m_Shortcut.WorkingDirectory = txtWorkingDir.Text; m_Shortcut.Arguments = txtArgs.Text; m_Shortcut.Description = txtDescription.Text; m_Shortcut.IconPath = txtIconFile.Text; m_Shortcut.IconIndex = Convert.ToInt32(txtIconIdx.Text); m_Shortcut.WindowStyle = (ProcessWindowStyle)cboWinStyle.SelectedItem; m_Shortcut.Save(); Icon ico = m_Shortcut.Icon; if (ico != null) { picIcon.Image = ico.ToBitmap(); ico.Dispose(); } else { picIcon.Image = null; } }
static void Main(string[] args) { // Name der zu erzeugenden Verknüpfungs-Datei string linkFileName = "c:\\eula.lnk"; // Pfad zu notepad.exe zusammenstellen string path = Path.Combine(Environment.SystemDirectory, "notepad.exe"); // Argumente für den Aufruf string arguments = Path.Combine(Environment.SystemDirectory, "eula.txt"); // Instanz der Klasse ShellShortcut erzeugen ShellShortcut ssh = new ShellShortcut(linkFileName); // ShellShortcut-Objekt initialisieren ssh.Description = "Test-Verknpfung"; // Beschreibung ssh.WorkingDirectory = "c:\\"; // Arbeitsverzeichnis ssh.Path = path; // Pfad zur Datei / zum Ordner ssh.Arguments = arguments; // Aufruf-Argumente ssh.IconPath = linkFileName; // Pfad zur Icon-Datei ssh.IconIndex = 0; // Index des Icons try { // Verknpfung speichern ssh.Save(); Console.WriteLine("Fertig"); } catch (Exception ex) { Console.WriteLine("Fehler beim Anlegen der Verknpfung: {0}", ex.Message); } Console.ReadLine(); }
private void CreateShortcuts() { UpdateStatus("Creating shortcuts..."); UpdateProgress(99); string desktopPath; string startMenuPath; if (installOptions.InstallAllUsers) { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonDesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonStartMenu); } else { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup); } ShellShortcut shortcutDesktop = new ShellShortcut(desktopPath + "\\PMU Map Editor.lnk"); shortcutDesktop.Description = "Start the Pokémon Mystery Universe Map Editor!"; shortcutDesktop.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; shortcutDesktop.IconPath = installOptions.DestinationDirectory + "\\Graphics\\pmuicon.ico"; shortcutDesktop.Path = installOptions.DestinationDirectory + "\\MapEditor.exe"; shortcutDesktop.WorkingDirectory = installOptions.DestinationDirectory; shortcutDesktop.Save(); ShellShortcut shortcutStartMenu = new ShellShortcut(startMenuPath + "\\PMU Map Editor.lnk"); shortcutStartMenu.Description = "Start the Pokémon Mystery Universe Map Editor!"; shortcutStartMenu.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; shortcutStartMenu.IconPath = installOptions.DestinationDirectory + "\\Graphics\\pmuicon.ico"; shortcutStartMenu.Path = installOptions.DestinationDirectory + "\\MapEditor.exe"; shortcutStartMenu.WorkingDirectory = installOptions.DestinationDirectory; shortcutStartMenu.Save(); }
//Kopieren der Dateien beendet private void bgwCopy_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { taskBarManager.Instance.setTaskBarProgressState(taskBarProgressState.NoProgress); if (e.Result == null) { // mit Erfolg try { //Verknüpfungen erstellen string administrationPath = Path.Combine(Context.installationDirectory, Context.Product.mainExecutable); // Auf dem Desktop if (Context.createDesktopShortcut) { var shortcutDesktop = new ShellShortcut(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "updateSystem.NET Administration.lnk")) {IconIndex = 0, IconPath = administrationPath, Path = administrationPath}; shortcutDesktop.Save(); } //Im Startmenu if (Context.createStartMenuShortcut) { var shortcutStartMenu = new ShellShortcut(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "updateSystem.NET Administration.lnk")) {IconIndex = 0, IconPath = administrationPath, Path = administrationPath}; shortcutStartMenu.Save(); } //Uninstalldaten in die Registry schreiben if (IsUserAnAdmin()) { ProgramsAndFeaturesHelper.Add(Context); } //Installer zwecks deinstallation ins Programmverzeichnis kopieren File.Copy(Application.ExecutablePath, Path.Combine(Context.installationDirectory, Context.Product.setupName), true); //Nur in Releaseversion Dateitypen registrieren if (Context.Product.GetType() == typeof (productRTM)) { //Neuen UDPROJX-Type registrieren FileAssociation.Associate( ".udprojx", Context.Product.applicationID, "updateSystem.NET Projektdatei", Path.Combine(Context.installationDirectory, "Project.ico"), administrationPath); //Alten UDPROJ-Type registrieren wenn dieser nicht bereits von der alten Installation registriert wurde if (!FileAssociation.IsAssociated(".udproj")) { FileAssociation.Associate( ".udproj", Context.Product.applicationID, "Alte updateSystem.NET Projektdatei", Path.Combine(Context.installationDirectory, "Project.ico"), administrationPath); } //Shell aktualisieren FileAssociation.refreshDesktop(); } //"Fertig"-Seite anzeigen onChangePage(new changePageEventArgs(typeof (stpInstalled))); } catch (Exception exc) { Context.setupException = exc; onChangePage(new changePageEventArgs(typeof (stpInterrupted))); } } else { // mit Exception Context.setupException = (e.Result as Exception); onChangePage(new changePageEventArgs(typeof (stpInterrupted))); } }
/// <summary> /// Create a shortcut in the current user's start menu /// Only do current user to avoid need for admin elevation /// </summary> /// <param name="targetExe"></param> protected InstallationResult CreateShortcuts(string targetExe) { // get path to users start menu var startMenu = StartMenuPath; if (!Directory.Exists(startMenu)) Directory.CreateDirectory(startMenu); Trace.TraceInformation("Creating start menu shortcut {0}", Path.Combine(startMenu, FriendlyName + ".lnk")); var product = new ShellShortcut(Path.Combine(startMenu, FriendlyName + ".lnk")) { Path = targetExe, Description = "Run " + FriendlyName }; product.Save(); if (PackageName == "MBServer") { var path = Path.Combine(startMenu, "Emby Server Dashboard.lnk"); Trace.TraceInformation("Creating dashboard shortcut {0}", path); var dashboard = new ShellShortcut(path) { Path = @"http://localhost:8096/web/dashboard.html", Description = "Open the Emby Server Dashboard" }; dashboard.Save(); } return CreateUninstaller(Path.Combine(Path.GetDirectoryName(targetExe) ?? "", "MediaBrowser.Uninstaller.exe") + " " + (PackageName == "MBServer" ? "server" : "mbt"), targetExe); }
private void button2_Click(object sender, EventArgs e) { Step++; if (Step == 2) { Back.Enabled = true; panel1.Visible = false; panel2.Left = panel1.Left; panel2.Top = panel1.Top; panel2.Visible = true; rad2.Checked = true; label1.BackColor = Color.Transparent; label2.BackColor = Color.FromArgb(70, 255, 255, 255); } if (Step == 3) { if (!Directory.Exists(textBox1.Text)) { if (MessageBox.Show("The Directory does not exist. Create one?") == DialogResult.OK) { if (Directory.CreateDirectory(textBox1.Text).Exists) { Back.Enabled = false; Next.Enabled = false; panel2.Visible = false; panel3.Left = panel1.Left; panel3.Top = panel1.Top; panel3.Visible = true; rad3.Checked = true; label2.BackColor = Color.Transparent; label3.BackColor = Color.FromArgb(70, 255, 255, 255); Install(); } } else { Step = 2; } } else { Directory.Delete(textBox1.Text, true); if (Directory.CreateDirectory(textBox1.Text).Exists) { panel2.Visible = false; panel3.Left = panel1.Left; panel3.Top = panel1.Top; panel3.Visible = true; rad3.Checked = true; label2.BackColor = Color.Transparent; label3.BackColor = Color.FromArgb(70, 255, 255, 255); Install(); } } } if (Step == 4) { if (checkBox2.Checked == true) { string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string app = System.Reflection.Assembly.GetExecutingAssembly().Location; string icon = app.Replace('\\', '/'); m_Shortcut.Path = "%SystemRoot%\\explorer.exe"; m_Shortcut.WorkingDirectory = "C:\\"; m_Shortcut.Arguments = ""; m_Shortcut.Description = "Silverlight Designer is used to make designing Silverlight applications easier."; m_Shortcut.IconPath = icon; m_Shortcut.IconIndex = 0; m_Shortcut.WindowStyle = ProcessWindowStyle.Normal; m_Shortcut.Save(); } if (checkBox1.Checked == true) { System.Diagnostics.Process.Start(textBox1.Text + Files[0]); } Close(); } }
private void buttonShortcut_Click(object sender, EventArgs e) { if (!_MacroNameValid) return; string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string macroName = MacroName; string shortcutPath = Path.Combine(desktopPath, String.Format("Macro - {0}.lnk", macroName)); ShellShortcut shortcut = new ShellShortcut(shortcutPath); string translatorFolder = SystemRegistry.GetInstallFolder(); if (translatorFolder==null) translatorFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); shortcut.Arguments = String.Format("-MACRO \"{0}\"", macroName); shortcut.Description = "Launch Macro: " + macroName; shortcut.Path = Path.Combine(translatorFolder, "Translator.exe"); shortcut.WorkingDirectory = translatorFolder; //shortcut.WindowStyle = ProcessWindowStyle.Normal; shortcut.Save(); }
/// <summary> /// We create our own logger from this constructor /// </summary> public Bootstrapper() { m_Logger = new TobiLoggerFacade(); Console.WriteLine(@"CONSOLE -- Testing redirection from System.Console.WriteLine() to the application logger."); Debug.WriteLine(@"DEBUG -- Testing redirection from System.Diagnostics.Debug.WriteLine() to the application logger. This message should not appear in RELEASE mode (only when DEBUG flag is set)."); Trace.WriteLine(@"TRACE -- Testing redirection from System.Diagnostics.Trace.WriteLine() to the application logger. This message should not appear in RELEASE mode (and in DEBUG mode only when TRACE flag is set)."); //System.Globalization.CultureInfo.ClearCachedData(); TimeZoneInfo.ClearCachedData(); m_Logger.Log(@"[" + DateTime.Now.ToString("yyyy-MM-dd_HH:mm:ss_K", CultureInfo.InvariantCulture) + @"]", Category.Info, Priority.High); m_Logger.Log(@"[" + DateTime.UtcNow.ToString("yyyy-MM-dd_HH:mm:ss_K", CultureInfo.InvariantCulture) + @"]", Category.Info, Priority.High); m_Logger.Log(@"[" + ApplicationConstants.LOG_FILE_PATH + @"]", Category.Info, Priority.High); m_Logger.Log(@"[Tobi version: " + ApplicationConstants.APP_VERSION + @"]", Category.Info, Priority.High); m_Logger.Log(@"[OS version: " + ApplicationConstants.OS_INFORMATION + @"]", Category.Info, Priority.High); m_Logger.Log(@"[ClickOnce: " + (ApplicationDeployment.IsNetworkDeployed ? "yes" : "no") + @"]", Category.Info, Priority.High); //0 => No graphics hardware acceleration available for the application on the device. //1 => Partial graphics hardware acceleration available on the video card. This corresponds to a DirectX version that is greater than or equal to 7.0 and less than 9.0. //2 => A rendering tier value of 2 means that most of the graphics features of WPF should use hardware acceleration provided the necessary system resources have not been exhausted. This corresponds to a DirectX version that is greater than or equal to 9.0. int renderingTier = (RenderCapability.Tier >> 16); m_Logger.Log(@"[Bootstrapper RenderCapability.Tier: " + renderingTier + @"]", Category.Info, Priority.High); string appFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); m_Logger.Log(@"[Tobi app data and log folder: " + ExternalFilesDataManager.STORAGE_FOLDER_PATH + @"]", Category.Info, Priority.High); m_Logger.Log(@"[Tobi exe folder: " + appFolder + @"]", Category.Info, Priority.High); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); m_Logger.Log(@"[Tobi user config folder: " + Path.GetDirectoryName(config.FilePath) + @"]", Category.Info, Priority.High); //#if ENABLE_LOG_DESKTOP_SHORTCUT string logPath = ApplicationConstants.LOG_FILE_PATH; //Path.Combine(appFolder, ApplicationConstants.LOG_FILE_NAME); string iconPath = Path.Combine(appFolder, "Shortcut.ico"); string shortcutToLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) #if NET40 , "Tobi log (.NET4).lnk" #else , "Tobi log (.NET3).lnk" #endif ); //#if !DEBUG if (File.Exists(shortcutToLogPath)) { try { File.Delete(shortcutToLogPath); } catch (Exception ex) { #if DEBUG Debugger.Break(); #endif } } try { using (var shortcut = new ShellShortcut(shortcutToLogPath)) { shortcut.Arguments = ""; shortcut.Description = "Shortcut to the Tobi log file"; //shortcut.IconPath = iconPath; shortcut.Path = logPath; shortcut.WorkingDirectory = appFolder; shortcut.Save(); } } catch (Exception ex) { m_Logger.Log(@"Can't create Tobi desktop shortcut!", Category.Exception, Priority.High); ExceptionHandler.LogException(ex); #if DEBUG Debugger.Break(); #endif } //#endif // DEBUG //#endif //ENABLE_LOG_DESKTOP_SHORTCUT foreach (Assembly item in AppDomain.CurrentDomain.GetAssemblies()) { if (item.GlobalAssemblyCache) { if (!string.IsNullOrEmpty(item.FullName) && item.FullName.Contains("mscorlib")) { Console.WriteLine(item.FullName); Console.WriteLine(item.Location); Console.WriteLine(item.ImageRuntimeVersion); //Console.WriteLine(item.GetName()); //Console.WriteLine(item.CodeBase); } } } if (true || ApplicationDeployment.IsNetworkDeployed) { if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0) { string path = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]; Console.WriteLine(@"APP PARAMETER: " + path); } } // WshShellClass wsh = new WshShellClass(); // IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut( // Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\shorcut.lnk") as IWshRuntimeLibrary.IWshShortcut; // shortcut.Arguments = "c:\\app\\settings1.xml"; // shortcut.TargetPath = "c:\\app\\myftp.exe"; // // not sure about what this is for // shortcut.WindowStyle = 1; // shortcut.Description = "my shortcut description"; // shortcut.WorkingDirectory = "c:\\app"; // shortcut.IconLocation = "specify icon location"; // shortcut.Save(); //private void appShortcutToDesktop(string linkName) //{ // string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); // using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url")) // { // string app = System.Reflection.Assembly.GetExecutingAssembly().Location; // writer.WriteLine("[InternetShortcut]"); // writer.WriteLine("URL=file:///" + app); // writer.WriteLine("IconIndex=0"); // string icon = app.Replace('\\', '/'); // writer.WriteLine("IconFile=" + icon); // writer.Flush(); // } //} //Set Shell = CreateObject("WScript.Shell") //DesktopPath = Shell.SpecialFolders("Desktop") //Set link = Shell.CreateShortcut(DesktopPath & "\test.lnk") //link.Arguments = "1 2 3" //link.Description = "test shortcut" //link.HotKey = "CTRL+ALT+SHIFT+X" //link.IconLocation = "app.exe,1" //link.TargetPath = "c:\blah\app.exe" //link.WindowStyle = 3 //link.WorkingDirectory = "c:\blah" //link.Save }
//Kopieren der Dateien beendet private void bgwCopy_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { taskBarManager.Instance.setTaskBarProgressState(taskBarProgressState.NoProgress); if (e.Result == null) { // mit Erfolg try { //Verknüpfungen erstellen string administrationPath = Path.Combine(Context.installationDirectory, Context.Product.mainExecutable); // Auf dem Desktop if (Context.createDesktopShortcut) { var shortcutDesktop = new ShellShortcut(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "updateSystem.NET Administration.lnk")) { IconIndex = 0, IconPath = administrationPath, Path = administrationPath }; shortcutDesktop.Save(); } //Im Startmenu if (Context.createStartMenuShortcut) { var shortcutStartMenu = new ShellShortcut(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "updateSystem.NET Administration.lnk")) { IconIndex = 0, IconPath = administrationPath, Path = administrationPath }; shortcutStartMenu.Save(); } //Uninstalldaten in die Registry schreiben if (IsUserAnAdmin()) { ProgramsAndFeaturesHelper.Add(Context); } //Installer zwecks deinstallation ins Programmverzeichnis kopieren File.Copy(Application.ExecutablePath, Path.Combine(Context.installationDirectory, Context.Product.setupName), true); //Nur in Releaseversion Dateitypen registrieren if (Context.Product.GetType() == typeof(productRTM)) { //Neuen UDPROJX-Type registrieren FileAssociation.Associate( ".udprojx", Context.Product.applicationID, "updateSystem.NET Projektdatei", Path.Combine(Context.installationDirectory, "Project.ico"), administrationPath); //Alten UDPROJ-Type registrieren wenn dieser nicht bereits von der alten Installation registriert wurde if (!FileAssociation.IsAssociated(".udproj")) { FileAssociation.Associate( ".udproj", Context.Product.applicationID, "Alte updateSystem.NET Projektdatei", Path.Combine(Context.installationDirectory, "Project.ico"), administrationPath); } //Shell aktualisieren FileAssociation.refreshDesktop(); } //"Fertig"-Seite anzeigen onChangePage(new changePageEventArgs(typeof(stpInstalled))); } catch (Exception exc) { Context.setupException = exc; onChangePage(new changePageEventArgs(typeof(stpInterrupted))); } } else { // mit Exception Context.setupException = (e.Result as Exception); onChangePage(new changePageEventArgs(typeof(stpInterrupted))); } }
static void InstallShortcut() { try { string lnkLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.SendTo), "Batch Clean.lnk"); ShellShortcut lnk = new ShellShortcut(lnkLocation); lnk.Description = Resources.OPEN_DIALOG_TITLE; lnk.Path = Assembly.GetExecutingAssembly().Location; lnk.Save(); } catch (Exception ex) { Logger.LogError("Failed to create batch clean shortcut"); Logger.LogError(ex); } }
/// <summary> /// Save the Metadata, if these have changed /// </summary> public void Save() { LimeMsg.Debug("LimeMetadata Save: modified: {0}", Modified); if (!Modified) { return; } // Save Media if (TagLibFile != null && TagLibFile.Tag != null) { LimeMsg.Debug("LimeMetadata Save: TagLibFile: {0}", TagLibFile.Name); bool isVideo = Type == MediaType.Video; string[] genres = null; if (Get("Genres")?.Content is StringComposite <string> compgenres) { genres = compgenres.ToArray(); } TagLibFile.Tag.Genres = genres; string conductor = null; if (Get(isVideo ? "Director" : "Conductor")?.Content is string person) { conductor = person; } TagLibFile.Tag.Conductor = conductor; string[] performers = null; string[] performersRole = null; if (Get(isVideo ? "Actors" : "Artists")?.Content is StringComposite <LimePerson> comppers && comppers.Collection != null) { var persons = comppers.Collection; performers = new string[persons.Count]; performersRole = new string[persons.Count]; for (int i = 0; i < persons.Count; i++) { performers[i] = persons[i].Name; performersRole[i] = persons[i].Roles != null? string.Join("; ", persons[i].Roles) : null; } } TagLibFile.Tag.Performers = performers; TagLibFile.Tag.PerformersRole = performersRole; TagLibFile.Tag.SetInfoTag(); TagLibFile.Save(); } // Save Link var lnk = Get("LinkTarget"); if (lnk != null) { var path = Get("Path"); LimeMsg.Debug("LimeMetadata Save: Link: {0}", path.Value); using (var link = new ShellShortcut(path.Value)) { if (!lnk.ReadOnly) { link.Path = lnk.Value; } link.WorkingDirectory = Get("LinkWorkdir").Value; link.Description = Get("LinkComment").Value; //link.Hotkey = (System.Windows.Forms.Keys)Get("LinkKey").Content; link.WindowStyle = (System.Diagnostics.ProcessWindowStyle)Get("LinkWindowStyle").Content; link.Arguments = Get("LinkArguments")?.Value; link.Save(); } } LimeMsg.Debug("LimeMetadata Save: done"); }
private void CreateShortcuts() { UpdateStatus("Creating shortcuts..."); UpdateProgress(99); string desktopPath; string startMenuPath; if (installOptions.InstallAllUsers) { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonDesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonStartMenu); } else { desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); startMenuPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup); } ShellShortcut shortcutDesktop = new ShellShortcut(desktopPath + "\\Pokemon Mystery Universe.lnk"); shortcutDesktop.Description = "Play Pokémon Mystery Universe!"; shortcutDesktop.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; shortcutDesktop.IconPath = installOptions.DestinationDirectory + "\\pmuicon.ico"; shortcutDesktop.Path = installOptions.DestinationDirectory + "\\PMU.exe"; shortcutDesktop.WorkingDirectory = installOptions.DestinationDirectory; shortcutDesktop.Save(); ShellShortcut shortcutStartMenu = new ShellShortcut(startMenuPath + "\\Pokemon Mystery Universe.lnk"); shortcutStartMenu.Description = "Play Pokémon Mystery Universe!"; shortcutStartMenu.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; shortcutStartMenu.IconPath = installOptions.DestinationDirectory + "\\pmuicon.ico"; shortcutStartMenu.Path = installOptions.DestinationDirectory + "\\PMU.exe"; shortcutStartMenu.WorkingDirectory = installOptions.DestinationDirectory; shortcutStartMenu.Save(); }
private void CreateShortcutForMacro(object sender, EventArgs e) { if (listViewMacro.SelectedItems.Count != 1) return; string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string macroName = listViewMacro.SelectedItems[0].Text; string shortcutPath = Path.Combine(desktopPath, String.Format("Macro - {0}.lnk", macroName)); ShellShortcut shortcut = new ShellShortcut(shortcutPath); string translatorFolder = Path.Combine(SystemRegistry.GetInstallFolder(), "Translator"); //shortcut.Arguments = String.Format("-MACRO \"{0}\"", Path.Combine(Program.FolderMacros, macroName + Common.FileExtensionMacro)); shortcut.Arguments = String.Format("-MACRO \"{0}\"", macroName); shortcut.Description = "Launch Macro: " + macroName; shortcut.Path = Path.Combine(translatorFolder, "Translator.exe"); shortcut.WorkingDirectory = translatorFolder; shortcut.WindowStyle = ProcessWindowStyle.Normal; shortcut.Save(); }
private static void SetShortcuts(String destinationPath, String culture) { String deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); ShellShortcut shortcut = new ShellShortcut(Path.Combine(deskDir, "DtPad.lnk")) { Path = Path.Combine(destinationPath, "DtPad.exe"), WorkingDirectory = destinationPath, Description = LanguageUtil.GetCurrentLanguageString("LinkLaunchDtPad", className, culture), IconPath = Path.Combine(destinationPath, "Icons\\DtPad.ico") }; shortcut.Save(); String startDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "DtPad"); if (!Directory.Exists(startDir)) { Directory.CreateDirectory(startDir); } StreamWriter textFile = File.CreateText(Path.Combine(startDir, String.Format("{0}.url", LanguageUtil.GetCurrentLanguageString("LinkWebsite", className, culture)))); textFile.WriteLine("[InternetShortcut]"); textFile.WriteLine("URL={0}", ConstantUtil.dtPadURL); textFile.WriteLine("IconIndex=0"); textFile.WriteLine("IconFile=" + Path.Combine(destinationPath, "Icons\\Dt.ico")); textFile.Close(); shortcut = new ShellShortcut(Path.Combine(startDir, "DtPad.lnk")) { Path = Path.Combine(destinationPath, "DtPad.exe"), WorkingDirectory = destinationPath, Description = LanguageUtil.GetCurrentLanguageString("LinkLaunchDtPad", className, culture), IconPath = Path.Combine(destinationPath, "Icons\\DtPad.ico") }; shortcut.Save(); shortcut = new ShellShortcut(Path.Combine(startDir, "DtPad Updater.lnk")) { Path = Path.Combine(destinationPath, "DtPadUpdater.exe"), WorkingDirectory = destinationPath, Description = LanguageUtil.GetCurrentLanguageString("LinkLaunchDtPadUpdater", className, culture), IconPath = Path.Combine(destinationPath, "Icons\\DtPadUpdater.ico") }; shortcut.Save(); shortcut = new ShellShortcut(Path.Combine(startDir, "DtPad Uninstaller.lnk")) { Path = Path.Combine(destinationPath, "DtPadUninstaller.exe"), WorkingDirectory = destinationPath, Description = LanguageUtil.GetCurrentLanguageString("LinkLaunchDtPadUninstaller", className, culture), IconPath = Path.Combine(destinationPath, "Icons\\DtPadUninstaller.ico") }; shortcut.Save(); //shortcut = new ShellShortcut(Path.Combine(startDir, LanguageUtil.GetCurrentLanguageString("LinkReadmeLabel", className, culture))) // { // Path = Path.Combine(destinationPath, "Readme.txt"), // WorkingDirectory = destinationPath, // Description = LanguageUtil.GetCurrentLanguageString("LinkReadme", className, culture), // }; //shortcut.Save(); }