private void removeFromStartUp() { string pathToStartUp = Environment.GetFolderPath(Environment.SpecialFolder.Startup); if (File.Exists(pathToStartUp + "\\" + dynamixStartupEntryName)) { File.Delete(pathToStartUp + "\\" + dynamixStartupEntryName); success StartUpRemoved = new success("The startup entry for the Dynamix DNS Client was successfully deleted.\n\nDynamix DNS Client will NOT start with Windows!"); StartUpRemoved.ShowDialog(); } else { MessageBox.Show("There is no startup entry to delete!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void addToStartUp() { string pathToStartUp = Environment.GetFolderPath(Environment.SpecialFolder.Startup); if (!File.Exists(pathToStartUp + "\\" + dynamixStartupEntryName)) { using (ShellLink shortcut = new ShellLink()) { shortcut.Target = Application.ExecutablePath; shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath); shortcut.Description = "Dynamix DNS Client"; shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal; //MessageBox.Show(pathToStartUp, "info"); shortcut.Save(pathToStartUp + "\\" + dynamixStartupEntryName); } success StartUpCreated = new success("A startup entry for the Dynamix DNS Client was successfully created.\n\nDynamix DNS Client will start with Windows!"); StartUpCreated.ShowDialog(); } else { MessageBox.Show("The startup entry already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }