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.IO;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace StarfaceOutlookSync.Models
|
||||
|
|
@ -8,6 +9,7 @@ namespace StarfaceOutlookSync.Models
|
|||
{
|
||||
public bool StartMinimized { get; set; } = false;
|
||||
public bool SyncOnStart { get; set; } = false;
|
||||
public bool AutoAcceptOutlookPrompt { get; set; } = false;
|
||||
|
||||
private static readonly string SettingsFile = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
|
|
@ -33,6 +35,45 @@ namespace StarfaceOutlookSync.Models
|
|||
File.WriteAllText(SettingsFile, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
}
|
||||
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();
|
||||
RefreshProfileList();
|
||||
|
||||
// Minimiert starten falls in Einstellungen aktiviert
|
||||
// Einstellungen laden und anwenden
|
||||
var settings = UserSettings.Load();
|
||||
settings.ApplyOutlookSecuritySetting();
|
||||
|
||||
if (settings.StartMinimized)
|
||||
{
|
||||
WindowState = FormWindowState.Minimized;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace StarfaceOutlookSync.UI
|
|||
{
|
||||
public class SettingsForm : Form
|
||||
{
|
||||
private CheckBox _chkStartMinimized, _chkSyncOnStart;
|
||||
private CheckBox _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook;
|
||||
private Button _btnSave, _btnCancel;
|
||||
private readonly UserSettings _settings;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ namespace StarfaceOutlookSync.UI
|
|||
private void InitializeComponent()
|
||||
{
|
||||
Text = "Einstellungen";
|
||||
Size = new Size(350, 210);
|
||||
Size = new Size(380, 250);
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
|
|
@ -40,20 +40,27 @@ namespace StarfaceOutlookSync.UI
|
|||
Checked = _settings.SyncOnStart
|
||||
};
|
||||
|
||||
_chkAutoAcceptOutlook = new CheckBox
|
||||
{
|
||||
Text = "Outlook-Sicherheitsabfrage automatisch erlauben",
|
||||
Left = 20, Top = 80, AutoSize = true,
|
||||
Checked = _settings.AutoAcceptOutlookPrompt
|
||||
};
|
||||
|
||||
_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
|
||||
};
|
||||
_btnSave.Click += (s, e) => Save();
|
||||
|
||||
_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
|
||||
};
|
||||
|
||||
Controls.AddRange(new Control[] { _chkStartMinimized, _chkSyncOnStart, _btnSave, _btnCancel });
|
||||
Controls.AddRange(new Control[] { _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook, _btnSave, _btnCancel });
|
||||
AcceptButton = _btnSave;
|
||||
CancelButton = _btnCancel;
|
||||
}
|
||||
|
|
@ -62,6 +69,7 @@ namespace StarfaceOutlookSync.UI
|
|||
{
|
||||
_settings.StartMinimized = _chkStartMinimized.Checked;
|
||||
_settings.SyncOnStart = _chkSyncOnStart.Checked;
|
||||
_settings.AutoAcceptOutlookPrompt = _chkAutoAcceptOutlook.Checked;
|
||||
_settings.Save();
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
|
|
|||
Loading…
Reference in New Issue