Skip to content

Commit

Permalink
Ignore access denied to set run on startup
Browse files Browse the repository at this point in the history
If the user doesn't have write access (or their AV is preventing access)
to SOFTWARE\Microsoft\Windows\CurrentVersion\Run, ignore the problem
gracefully instead of crashing.
  • Loading branch information
ribbons committed Oct 12, 2014
1 parent 7d2d043 commit 2b64de7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Classes/OsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,17 @@ internal static bool CompositionEnabled()

internal static void ApplyRunOnStartup()
{
RegistryKey runKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
RegistryKey runKey;

try
{
runKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
}
catch (UnauthorizedAccessException)
{
// Access denied by non-standard ACL or antivirus
return;
}

if (Settings.RunOnStartup)
{
Expand Down

0 comments on commit 2b64de7

Please sign in to comment.