diff --git a/src/windows2go.switcher/FormMain.cs b/src/windows2go.switcher/FormMain.cs index f6c6f4a..2fc80cb 100644 --- a/src/windows2go.switcher/FormMain.cs +++ b/src/windows2go.switcher/FormMain.cs @@ -11,18 +11,25 @@ using System.Windows.Forms; namespace windows2go.switcher { public partial class FormMain : Form { + + RegistryKey key = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Default); + + const string keyName ="HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control"; + public FormMain() { InitializeComponent(); - if (!UACSecurity.IsAdmin()) { - UACSecurity.AddShieldToButton(buttonSetNormal); - UACSecurity.AddShieldToButton(buttonSetPortable); - } else - this.Text += " (Administrator)"; + UACSecurity.AddShieldToButton(buttonSetNormal); + UACSecurity.AddShieldToButton(buttonSetPortable); + // if (!UACSecurity.IsAdmin()) { + // + // + // } else + // this.Text += " (Administrator)"; } - bool PortableState = false; - bool KeyExists = false; - bool unExpected=false; + bool PortableState; + bool KeyExists; + bool unExpected; private void FormMain_Load(object sender, EventArgs e) { FullRegistryCheck(); @@ -48,9 +55,9 @@ namespace windows2go.switcher { } private void GetState() { - RegistryKey key = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32); - key = key.OpenSubKey(@"SYSTEM\CurrentControlSet\Control"); + RegistryKey key = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32); + key = key.OpenSubKey(@"SYSTEM\CurrentControlSet\Control", true); //check for exists "PortableOperatingSystem" if (key != null) { switch (key.GetValue("PortableOperatingSystem")) { @@ -95,32 +102,17 @@ namespace windows2go.switcher { } private void buttonSetNormal_Click(object sender, EventArgs e) { - if (UACSecurity.IsAdmin()) { - switch (unExpected) { - case true: - MessageBox.Show("oh no.", ""); - FullRegistryCheck(); - break; + Registry.SetValue(keyName, "PortableOperatingSystem", 0); + FullRegistryCheck(); + + - case false: - MessageBox.Show("yay.", ""); - FullRegistryCheck(); - break; - } - } else { - UACSecurity.RestartElevated(); - } } private void buttonSetPortable_Click(object sender, EventArgs e) { - if (UACSecurity.IsAdmin()) { - MessageBox.Show("okay.", ""); - FullRegistryCheck(); - } else { - UACSecurity.RestartElevated(); - } - + Registry.SetValue(keyName, "PortableOperatingSystem", 1); + } } diff --git a/src/windows2go.switcher/Properties/AssemblyInfo.cs b/src/windows2go.switcher/Properties/AssemblyInfo.cs index 0cf7504..f5d44cc 100644 --- a/src/windows2go.switcher/Properties/AssemblyInfo.cs +++ b/src/windows2go.switcher/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/src/windows2go.switcher/app.manifest b/src/windows2go.switcher/app.manifest new file mode 100644 index 0000000..c5f817a --- /dev/null +++ b/src/windows2go.switcher/app.manifest @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/windows2go.switcher/windows2go.switcher.csproj b/src/windows2go.switcher/windows2go.switcher.csproj index 229826f..bca31cd 100644 --- a/src/windows2go.switcher/windows2go.switcher.csproj +++ b/src/windows2go.switcher/windows2go.switcher.csproj @@ -35,6 +35,9 @@ windows.ico + + app.manifest + @@ -70,6 +73,7 @@ True Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs