Exemple #1
0
        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();
            }
        }
Exemple #2
0
        /// <summary>
        /// Show the application dialog and return selection
        /// </summary>
        /// <param name="enableDirectory">Enable to create new direcoty.</param>
        /// <returns>selected application, null if cancel/fail</returns>
        private static string AppDialog(bool enableDirectory = true)
        {
            FolderBrowser fb = new FolderBrowser
            {
                Description         = Global.Properties["ItemAddApp"].Desc,
                IncludeFiles        = true,
                ShowNewFolderButton = enableDirectory
            };

            // Retrieve the Application Folder
            if (LimeLib.IsWindows8)
            {
                ShellShortcut link = new ShellShortcut(ConfigLocal.AppsFolderPath);
                IntPtr        pidl = link.PIDL;
                LimeMsg.Debug("AppDialog: AppsFolder PIDL: {0}", pidl.ToInt32());
                fb.RootPIDL         = pidl;
                fb.InitialDirectory = String.Format(":{0}", pidl.ToInt32());
            }
            else
            {
                fb.RootFolderID = FolderBrowser.FolderID.StartMenu;
                LimeMsg.Debug("AppDialog: AppsFolder FolderID: {0}", fb.RootFolderID);
            }

            // Show the dialog
            if (fb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return(fb.SelectedPath);
            }

            return(null);
        }
Exemple #3
0
        /// <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));
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        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();
        }
        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;
        }
Exemple #7
0
        // --------------------------------------------------------------------------------------------------
        #region Class functions

        /// <summary>
        /// Resolve a file-path. Follows the links if the last element is a link.
        /// </summary>
        /// <param name="path">path to resolve</param>
        /// <returns>path after link-resolution. This can be a non-existing file/directory.</returns>
        public static string ResolvePath(string path)
        {
            while (true)
            {
                try
                {
                    if (Path.GetExtension(path).ToLower() == ".lnk")
                    {
                    }
                    else if (!File.Exists(path))
                    {
                        if (File.Exists(path + ".lnk"))
                        {
                            path += ".lnk";
                        }
                        else if (File.Exists(Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)) + ".lnk"))
                        {
                            path = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)) + ".lnk";
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }

                    ShellShortcut link = new ShellShortcut(path);
                    LimeMsg.Debug("LimeLib ResolvePath: link: {0}", path);
                    path = link.Path;

                    if (path == "" || IsNetworkDrive(path) || IsLibrary(path))
                    {
                        // Prefer PIDL to unhandled path-formats
                        IntPtr pidl = link.PIDL;
                        path = string.Format(":{0}", pidl);
                        break;
                    }
                }
                catch
                {
                    return(path);
                }
            }

            return(path);
        }
Exemple #8
0
        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 btnOpen_Click(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();

        ofd.CheckFileExists  = false;
        ofd.DefaultExt       = "lnk";
        ofd.DereferenceLinks = false;
        ofd.Title            = "Select a shortcut file";
        ofd.Filter           = "Shortcuts (*.lnk)|*.lnk|All files (*.*)|*.*";
        ofd.FilterIndex      = 1;

        if (ofd.ShowDialog() == DialogResult.OK)
        {
            m_Shortcut          = new ShellShortcut(ofd.FileName);
            lblCurrentFile.Text = ofd.FileName;

            txtTarget.Text      = m_Shortcut.Path;
            txtWorkingDir.Text  = m_Shortcut.WorkingDirectory;
            txtArgs.Text        = m_Shortcut.Arguments;
            txtDescription.Text = m_Shortcut.Description;
            txtIconFile.Text    = m_Shortcut.IconPath;
            txtIconIdx.Text     = m_Shortcut.IconIndex.ToString();

            cboWinStyle.SelectedIndex = cboWinStyle.Items.IndexOf(m_Shortcut.WindowStyle);
            lblHotkey.Text            = TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString(m_Shortcut.Hotkey);

            Icon ico = m_Shortcut.Icon;
            if (ico != null)
            {
                picIcon.Image = ico.ToBitmap();
                ico.Dispose();
            }
            else
            {
                picIcon.Image = null;
            }

            btnSave.Enabled         = true;
            btnBrowseTarget.Enabled = true;
            btnBrowseIcon.Enabled   = true;
        }

        ofd.Dispose();
    }
Exemple #10
0
        public IObservable <Settings> Save(Settings settings)
        {
            if (!settings.IsValidated)
            {
                throw new InvalidOperationException("Settings must be validated before saved.");
            }
            var result = new Subject <Settings>();

            Task.Run(async() => {
                Settings.Copy(settings, Settings);
                await Settings.WriteToStorage(_storage);

                // handle startup settings todo test!
                if (Settings.StartWithWindows)
                {
                    var linkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "VPDB", "VPDB Agent.lnk");
                    string cmd;
                    if (File.Exists(linkPath))
                    {
                        var lnk = new ShellShortcut(linkPath);
                        cmd     = $"cmd /c \"cd /d {lnk.WorkingDirectory} && {lnk.Path} {lnk.Arguments} --process-start-args \\\"--minimized\\\"\"";
                    }
                    else
                    {
                        cmd = File.Exists(linkPath) ? linkPath : Assembly.GetEntryAssembly().Location;
                    }
                    _registryKey.SetValue("VPDB Agent", cmd);
                }
                else
                {
                    if (_registryKey.GetValue("VPDB Agent") != null)
                    {
                        _registryKey.DeleteValue("VPDB Agent");
                    }
                }

                result.OnNext(Settings);
                result.OnCompleted();
            });

            CanCancel = true;
            return(result);
        }
        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();
              }
        }
Exemple #12
0
        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();
        }
Exemple #13
0
        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();
        }
		//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)));
			}
		}
Exemple #15
0
 private void ParseLinks()
 {
     foreach (var launchEntry in foundFiles) {
         var ext = Path.GetExtension(launchEntry.FullPath).ToLowerInvariant();
         if (ext == ".lnk") {
             using (var ss = new ShellShortcut(launchEntry.FullPath)) {
                 if(!string.IsNullOrEmpty(ss.Path)) launchEntry.LinkTarget = ss.Path;
             }
         }
     }
 }
Exemple #16
0
		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);
			}
		}
        //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>
        /// 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
        }
Exemple #19
0
		public IObservable<Settings> Save(Settings settings)
		{
			if (!settings.IsValidated) {
				throw new InvalidOperationException("Settings must be validated before saved.");
			}
			var result = new Subject<Settings>();

			Task.Run(async () => {
				Settings.Copy(settings, Settings);
				await Settings.WriteToStorage(_storage);

				// handle startup settings todo test!
				if (Settings.StartWithWindows)
				{
					var linkPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "VPDB", "VPDB Agent.lnk");
					string cmd;
					if (File.Exists(linkPath)) {
						var lnk = new ShellShortcut(linkPath);
						cmd = $"cmd /c \"cd /d {lnk.WorkingDirectory} && {lnk.Path} {lnk.Arguments} --process-start-args \\\"--minimized\\\"\"";
					} else {
						cmd = File.Exists(linkPath) ? linkPath : Assembly.GetEntryAssembly().Location;
					}
					_registryKey.SetValue("VPDB Agent", cmd);
				} else {
					if (_registryKey.GetValue("VPDB Agent") != null) {
						_registryKey.DeleteValue("VPDB Agent");
					}
				}

				result.OnNext(Settings);
				result.OnCompleted();
			});

			CanCancel = true;
			return result;
		}
Exemple #20
0
        private static Game getGameData(RegistryKey gKey)
        {
            Game   result = new Game();
            String guid   = (String)gKey.GetValue("ApplicationId");

            result.name = (String)gKey.GetValue("Title");
            String outIcon = outFolder + @"\" + guid + ".png";

            // Retrieve Path for executable
            String exePath = "";

            if (gKey.GetValue("AppExePath") != null)
            {
                exePath = (String)gKey.GetValue("AppExePath");
                if (!File.Exists(exePath))
                {
                    exePath = (String)gKey.GetValue("ConfigApplicationPath") + @"\" + (String)gKey.GetValue("AppExePath");
                }
            }
            if (!File.Exists(exePath))
            {
                String exeFile     = getExecutablePathFromGDF((String)gKey.GetValue("ConfigGDFBinaryPath"));
                String exeBasePath = (String)gKey.GetValue("ConfigApplicationPath") + @"\";
                exePath = exeBasePath + exeFile;
                exePath = exePath.Replace(@"\\", @"\");
                if (!File.Exists(exePath))
                {
                    String[] parts = exeFile.Split('\\');
                    for (int i = 0; i < parts.Length; i++)
                    {
                        parts[i] = "";
                        String merged = exeBasePath + String.Join(@"\", parts);
                        for (int j = 0; j < parts.Length; j++)
                        {
                            merged = merged.Replace(@"\\", @"\");
                        }
                        if (File.Exists(merged))
                        {
                            exePath = merged;
                            break;
                        }
                    }
                }
                Console.WriteLine("GDF File: " + exePath);
                Thread.Sleep(1000);
            }
            if (!File.Exists(exePath))
            {
                return(null);// throw new NotSupportedException();
            }
            result.exe = exePath;

            // Get Icon for Game
            //if (!File.Exists(outIcon))
            {
                FileInfo fi = new FileInfo(exePath);
                if (fi.Extension.ToLower() == ".lnk")
                {
                    String        iconPath     = "";
                    ShellShortcut fileShortcut = new ShellShortcut(exePath);
                    if (fileShortcut.Icon != null)
                    {
                        Bitmap   bmp = new Bitmap(32, 32);
                        Graphics g   = Graphics.FromImage(bmp);
                        g.DrawIcon(fileShortcut.Icon, 0, 0);
                        bmp.Save(outIcon, ImageFormat.Png);
                        bmp.Dispose();
                        g.Dispose();
                    }
                    else
                    {
                        iconPath = fileShortcut.IconPath;
                        // GetIconPath from link file
                        Bitmap bmp = new Bitmap(32, 32);
                        getShellIconAsImage(iconPath, out bmp);
                        bmp.Save(outIcon, ImageFormat.Png);
                        bmp.Dispose();
                    }
                }
                else
                {
                    Bitmap bmp = new Bitmap(32, 32);
                    getShellIconAsImage(exePath, out bmp);
                    bmp.Save(outIcon, ImageFormat.Png);
                    bmp.Dispose();
                }
            }
            result.icon = outIcon;

            // Get BoxArt from registry if available
            // Loading the thumbnail from resource is not available yet
            if (gKey.GetValue("BoxArt") != null)
            {
                result.boxArt = (String)gKey.GetValue("BoxArt");
            }
            return(result);
        }
    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();
    }
Exemple #22
0
        /// <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");
        }
Exemple #23
0
        /// <summary>
        /// Construct and retrieve Metadata from a directory/file path
        /// </summary>
        /// <param name="item">The <see cref="LimeItem"/> element to construct Metadata for.</param>
        /// <param name="coverOnly">Try to load only a cover, not the system icon</param>
        public LimeMetadata(LimeItem item, bool coverOnly) : this()
        {
            LimeLib.LifeTrace(this);

            // Disable modification detection
            _Modified = null;


            LimeMsg.Debug("LimeMetadata: {0}", item.Name);
            string path = item.Path;

            if (!coverOnly)
            {
                // Add Name
                Add("Name", item.Name, true, false);
                if (item.Link != null)
                {
                    // Link
                    path = item.Link;
                    Add("LinkLabel");
                }

                // Handle tasks
                if (item.Task)
                {
                    Add("Task", item.Name, true);
                }

                // Display path
                Add("Path", item, "Path", readOnly: item.Task);
            }

            // Retrieve Tags
            if (!item.Task && !item.Directory && !LimeLib.IsPIDL(path) && !LimeLib.IsSSPD(path))
            {
                LimeMsg.Debug("LimeMetadata: TagLib: {0}", item.Name);
                try
                {
                    TagLibFile = TagLib.File.Create(path, TagLib.ReadStyle.Average | TagLib.ReadStyle.PictureLazy);
                }
                catch
                {
                    LimeMsg.Debug("LimeMetadata: {0}: Failed TagLib.File.Create({1})", item.Name, path);
                }
            }

            // Extract Tags
            if (TagLibFile != null)
            {
                LimeMsg.Debug("LimeMetadata: TagLib done: {0}", item.Name);

                // Retrieve Type
                if (TagLibFile.Properties != null && TagLibFile.Properties.Codecs != null)
                {
                    TagLib.MediaTypes[] prioTypes = new TagLib.MediaTypes[] {
                        TagLib.MediaTypes.Video, TagLib.MediaTypes.Audio, TagLib.MediaTypes.Photo, TagLib.MediaTypes.Text
                    };

                    var codecs = TagLibFile.Properties.Codecs;
                    foreach (var codec in codecs)
                    {
                        if (codec != null)
                        {
                            TagLib.MediaTypes mask = codec.MediaTypes | (TagLib.MediaTypes)Type;

                            foreach (var typ in prioTypes)
                            {
                                if ((mask & typ) != 0)
                                {
                                    Type = (MediaType)typ;
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (TagLibFile is TagLib.Image.NoMetadata.File)
                {
                    Type = MediaType.Image;
                }
            }

            // Handle Links
            if (!coverOnly && item.Link != null)
            {
                using (var link = new ShellShortcut(item.Path))
                {
                    Add("LinkWorkdir", link.WorkingDirectory);
                    //Add("LinkKey", link.Hotkey);
                    Add("LinkWindowStyle", (ShellLinkWindowStyle)link.WindowStyle);

                    if (Type == MediaType.None)
                    {
                        Add("LinkArguments", link.Arguments);
                    }

                    Add("LinkComment", link.Description);
                }


                Add("TagLabel");

                // Target Path
                if (LimeLib.IsPIDL(item.Link))
                {
                    // Retrieve name of the PIDL
                    try
                    {
                        var dInfo = new DirectoryInfoEx(new ShellDll.PIDL(LimeLib.GetPIDL(item.Link), true));
                        Add("LinkTarget", dInfo.Label, true);
                    }
                    catch { }
                }
                else
                {
                    Add("LinkTarget", item.Link, LimeLib.IsSSPD(item.Link));
                }
            }


            if (TagLibFile != null)
            {
                LimeMsg.Debug("LimeMetadata: TagLib done 2: {0}", item.Name);
                // Build the Properties
                BuildProperties();


                // Build the Pictures image
                BuildCover(coverOnly);
            }
            else if (!coverOnly)
            {
                // Build the Pictures image from the file icon
                using (var bmp = item.Bitmap(256))
                {
                    Pictures = LimeLib.ImageSourceFrom(bmp);
                }
            }

            if (!coverOnly)
            {
                // Finalize
                BuildToolTip();
            }

            // re-enable modification detection
            _Modified = false;
            LimeMsg.Debug("LimeMetadata End: {0}", item.Name);
        }
Exemple #24
0
        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();
        }
Exemple #25
0
        private static Game getGameData(RegistryKey gKey)
        {
            Game result = new Game();
            String guid = (String)gKey.GetValue("ApplicationId");
            result.name = (String)gKey.GetValue("Title");
            String outIcon = outFolder + @"\" + guid + ".png";

            // Retrieve Path for executable
            String exePath = "";
            if (gKey.GetValue("AppExePath") != null)
            {
                exePath = (String)gKey.GetValue("AppExePath");
                if (!File.Exists(exePath))
                {
                    exePath = (String)gKey.GetValue("ConfigApplicationPath") + @"\" + (String)gKey.GetValue("AppExePath");
                }
            }
            if (!File.Exists(exePath))
            {
                String exeFile = getExecutablePathFromGDF((String)gKey.GetValue("ConfigGDFBinaryPath"));
                String exeBasePath = (String)gKey.GetValue("ConfigApplicationPath") + @"\";
                exePath = exeBasePath + exeFile;
                exePath = exePath.Replace(@"\\", @"\");
                if (!File.Exists(exePath))
                {
                    String[] parts = exeFile.Split('\\');
                    for (int i = 0; i < parts.Length; i++)
                    {
                        parts[i] = "";
                        String merged = exeBasePath+String.Join(@"\", parts);
                        for (int j = 0; j < parts.Length; j++)
                        {
                            merged = merged.Replace(@"\\", @"\");
                        }
                        if (File.Exists(merged))
                        {
                            exePath = merged;
                            break;
                        }
                    }
                }
                Console.WriteLine("GDF File: " + exePath);
                Thread.Sleep(1000);
            }
            if (!File.Exists(exePath))
            {
                return null;// throw new NotSupportedException();
            }
            result.exe = exePath;

            // Get Icon for Game
            //if (!File.Exists(outIcon))
            {
                FileInfo fi = new FileInfo(exePath);
                if (fi.Extension.ToLower() == ".lnk")
                {
                    String iconPath = "";
                    ShellShortcut fileShortcut = new ShellShortcut(exePath);
                    if (fileShortcut.Icon != null)
                    {
                        Bitmap bmp = new Bitmap(32, 32);
                        Graphics g = Graphics.FromImage(bmp);
                        g.DrawIcon(fileShortcut.Icon, 0, 0);
                        bmp.Save(outIcon, ImageFormat.Png);
                        bmp.Dispose();
                        g.Dispose();
                    }
                    else
                    {
                        iconPath = fileShortcut.IconPath;
                        // GetIconPath from link file
                        Bitmap bmp = new Bitmap(32, 32);
                        getShellIconAsImage(iconPath, out bmp);
                        bmp.Save(outIcon, ImageFormat.Png);
                        bmp.Dispose();
                    }
                }
                else
                {
                    Bitmap bmp = new Bitmap(32, 32);
                    getShellIconAsImage(exePath, out bmp);
                    bmp.Save(outIcon, ImageFormat.Png);
                    bmp.Dispose();
                }
            }
            result.icon = outIcon;

            // Get BoxArt from registry if available
            // Loading the thumbnail from resource is not available yet
            if (gKey.GetValue("BoxArt") != null)
            {
                result.boxArt = (String)gKey.GetValue("BoxArt");
            }
            return result;
        }
Exemple #26
0
        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();

        }
        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();
        }
        /// <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);

        }