private void MenuItemAutoStartClick(object sender, EventArgs e) { string keyName = AssemblyUtils.AssemblyProductName; string assemblyLocation = AssemblyUtils.AssemblyLocation; bool autoStartEnabled = AutoStarter.IsAutoStartByRegisterEnabled(keyName, assemblyLocation); if (autoStartEnabled) { AutoStarter.UnsetAutoStartByRegister(keyName); if (Environment.OSVersion.Version.Major >= 6) { AutoStarter.UnsetAutoStartByScheduler(keyName); } } else { AutoStarter.SetAutoStartByRegister(keyName, assemblyLocation); if (Environment.OSVersion.Version.Major >= 6) { AutoStarter.SetAutoStartByScheduler(keyName, assemblyLocation); } } ((ToolStripMenuItem)sender).Checked = !autoStartEnabled; }