Add option to suppress Outlook security prompt
New setting "Outlook-Sicherheitsabfrage automatisch erlauben" sets registry keys under HKCU\Policies\Microsoft\Office\16.0\ Outlook\Security to auto-approve Object Model Guard prompts. Applied at app startup and when saving settings. Disabling the option removes the registry values (back to Outlook default). Works with all Outlook versions (2016-2024, same registry path). No admin rights needed (HKCU). Outlook must be restarted after changing this setting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b7cc335184
commit
163dc17b49
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Microsoft.Win32;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace StarfaceOutlookSync.Models
|
namespace StarfaceOutlookSync.Models
|
||||||
|
|
@ -8,6 +9,7 @@ namespace StarfaceOutlookSync.Models
|
||||||
{
|
{
|
||||||
public bool StartMinimized { get; set; } = false;
|
public bool StartMinimized { get; set; } = false;
|
||||||
public bool SyncOnStart { get; set; } = false;
|
public bool SyncOnStart { get; set; } = false;
|
||||||
|
public bool AutoAcceptOutlookPrompt { get; set; } = false;
|
||||||
|
|
||||||
private static readonly string SettingsFile = Path.Combine(
|
private static readonly string SettingsFile = Path.Combine(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
|
|
@ -33,6 +35,45 @@ namespace StarfaceOutlookSync.Models
|
||||||
File.WriteAllText(SettingsFile, JsonConvert.SerializeObject(this, Formatting.Indented));
|
File.WriteAllText(SettingsFile, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
|
ApplyOutlookSecuritySetting();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyOutlookSecuritySetting()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var regPath = @"Software\Policies\Microsoft\Office\16.0\Outlook\Security";
|
||||||
|
|
||||||
|
if (AutoAcceptOutlookPrompt)
|
||||||
|
{
|
||||||
|
// Alle Outlook Object Model Guard Prompts unterdruecken
|
||||||
|
var key = Registry.CurrentUser.CreateSubKey(regPath);
|
||||||
|
key.SetValue("ObjectModelGuard", 2, RegistryValueKind.DWord);
|
||||||
|
key.SetValue("PromptOOMAddressBookAccess", 2, RegistryValueKind.DWord);
|
||||||
|
key.SetValue("PromptOOMAddressInformationAccess", 2, RegistryValueKind.DWord);
|
||||||
|
key.SetValue("AdminSecurityMode", 3, RegistryValueKind.DWord);
|
||||||
|
key.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Zurueck auf Standard (Werte loeschen)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var key = Registry.CurrentUser.OpenSubKey(regPath, true);
|
||||||
|
if (key != null)
|
||||||
|
{
|
||||||
|
try { key.DeleteValue("ObjectModelGuard"); } catch { }
|
||||||
|
try { key.DeleteValue("PromptOOMAddressBookAccess"); } catch { }
|
||||||
|
try { key.DeleteValue("PromptOOMAddressInformationAccess"); } catch { }
|
||||||
|
try { key.DeleteValue("AdminSecurityMode"); } catch { }
|
||||||
|
key.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,10 @@ namespace StarfaceOutlookSync.UI
|
||||||
SetupAutoSync();
|
SetupAutoSync();
|
||||||
RefreshProfileList();
|
RefreshProfileList();
|
||||||
|
|
||||||
// Minimiert starten falls in Einstellungen aktiviert
|
// Einstellungen laden und anwenden
|
||||||
var settings = UserSettings.Load();
|
var settings = UserSettings.Load();
|
||||||
|
settings.ApplyOutlookSecuritySetting();
|
||||||
|
|
||||||
if (settings.StartMinimized)
|
if (settings.StartMinimized)
|
||||||
{
|
{
|
||||||
WindowState = FormWindowState.Minimized;
|
WindowState = FormWindowState.Minimized;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ namespace StarfaceOutlookSync.UI
|
||||||
{
|
{
|
||||||
public class SettingsForm : Form
|
public class SettingsForm : Form
|
||||||
{
|
{
|
||||||
private CheckBox _chkStartMinimized, _chkSyncOnStart;
|
private CheckBox _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook;
|
||||||
private Button _btnSave, _btnCancel;
|
private Button _btnSave, _btnCancel;
|
||||||
private readonly UserSettings _settings;
|
private readonly UserSettings _settings;
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace StarfaceOutlookSync.UI
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
Text = "Einstellungen";
|
Text = "Einstellungen";
|
||||||
Size = new Size(350, 210);
|
Size = new Size(380, 250);
|
||||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||||
MaximizeBox = false;
|
MaximizeBox = false;
|
||||||
MinimizeBox = false;
|
MinimizeBox = false;
|
||||||
|
|
@ -40,20 +40,27 @@ namespace StarfaceOutlookSync.UI
|
||||||
Checked = _settings.SyncOnStart
|
Checked = _settings.SyncOnStart
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_chkAutoAcceptOutlook = new CheckBox
|
||||||
|
{
|
||||||
|
Text = "Outlook-Sicherheitsabfrage automatisch erlauben",
|
||||||
|
Left = 20, Top = 80, AutoSize = true,
|
||||||
|
Checked = _settings.AutoAcceptOutlookPrompt
|
||||||
|
};
|
||||||
|
|
||||||
_btnSave = new Button
|
_btnSave = new Button
|
||||||
{
|
{
|
||||||
Text = "Speichern", Left = 80, Top = 130, Width = 85, Height = 28,
|
Text = "Speichern", Left = 95, Top = 160, Width = 85, Height = 28,
|
||||||
DialogResult = DialogResult.None
|
DialogResult = DialogResult.None
|
||||||
};
|
};
|
||||||
_btnSave.Click += (s, e) => Save();
|
_btnSave.Click += (s, e) => Save();
|
||||||
|
|
||||||
_btnCancel = new Button
|
_btnCancel = new Button
|
||||||
{
|
{
|
||||||
Text = "Abbrechen", Left = 174, Top = 130, Width = 85, Height = 28,
|
Text = "Abbrechen", Left = 189, Top = 160, Width = 85, Height = 28,
|
||||||
DialogResult = DialogResult.Cancel
|
DialogResult = DialogResult.Cancel
|
||||||
};
|
};
|
||||||
|
|
||||||
Controls.AddRange(new Control[] { _chkStartMinimized, _chkSyncOnStart, _btnSave, _btnCancel });
|
Controls.AddRange(new Control[] { _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook, _btnSave, _btnCancel });
|
||||||
AcceptButton = _btnSave;
|
AcceptButton = _btnSave;
|
||||||
CancelButton = _btnCancel;
|
CancelButton = _btnCancel;
|
||||||
}
|
}
|
||||||
|
|
@ -62,6 +69,7 @@ namespace StarfaceOutlookSync.UI
|
||||||
{
|
{
|
||||||
_settings.StartMinimized = _chkStartMinimized.Checked;
|
_settings.StartMinimized = _chkStartMinimized.Checked;
|
||||||
_settings.SyncOnStart = _chkSyncOnStart.Checked;
|
_settings.SyncOnStart = _chkSyncOnStart.Checked;
|
||||||
|
_settings.AutoAcceptOutlookPrompt = _chkAutoAcceptOutlook.Checked;
|
||||||
_settings.Save();
|
_settings.Save();
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue