private void SetStatusAndSummary() { this.sideloadingStatus = this.SideloadingChecker.GetStatus(); switch (this.SideloadingStatus) { case SideloadingStatus.NotAllowed: this.Status = RecommendationStatus.Warning; this.Summary = "Only apps from Microsoft Store can be installed."; break; case SideloadingStatus.Sideloading: this.Status = RecommendationStatus.Success; this.Summary = "Sideloading of apps is enabled."; break; case SideloadingStatus.DeveloperMode: this.Status = RecommendationStatus.Success; this.Summary = "Developer mode is enabled."; break; default: throw new ArgumentOutOfRangeException(); } }
public override bool Set(SideloadingStatus status) { var allowSideloadDword = status != SideloadingStatus.NotAllowed ? 1 : 0; var allowDevModeDword = status == SideloadingStatus.DeveloperMode ? 1 : 0; var cmd1 = $@"reg.exe add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock /t REG_DWORD /f /v AllowAllTrustedApps /d {allowSideloadDword}"; var cmd2 = $@"reg.exe add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock /t REG_DWORD /f /v AllowDevelopmentWithoutDevLicense /d {allowDevModeDword}"; var psi = new ProcessStartInfo("cmd.exe") { Arguments = "/c \"" + cmd1 + " && " + cmd2 + "\"", UseShellExecute = true, WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System), Verb = "runas", #if !DEBUG WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true #endif }; try { var p = Process.Start(psi); if (p == null) { return(false); } if (!p.WaitForExit(2000)) { return(false); } if (p.ExitCode != 0) { return(false); } } catch (Exception) { return(false); } return(this.Get() == status); }
public override bool Set(SideloadingStatus status) { this.AssertConfiguratorSetForWindowsVersion(); return(this.sideloadingConfigurator.Set(status)); }
public abstract bool Set(SideloadingStatus status);