public static async Task <DismFeatureInfo> EnableWindowsFeatures(string featureName, DismProgressCallback dismProgressCallback) { if (string.IsNullOrWhiteSpace(featureName)) { throw new ArgumentException(); } DismApi.Initialize(DismLogLevel.LogErrors); DismFeatureInfo retVal; try { using (var session = DismApi.OpenOnlineSession()) { DismApi.EnableFeatureByPackageName(session, featureName, null, false, true, new List <string>(), dismProgressCallback); retVal = DismApi.GetFeatureInfo(session, featureName); } } finally { DismApi.Shutdown(); } await Task.Delay(200).ConfigureAwait(false); return(retVal); }
public async Task EnableFeatureAsync(string featureName) => DismApi.EnableFeatureByPackageName(await GetDismSessionAsync(), featureName, null, false, true);
public override Task InstallPackageAsync(SoftwarePackage package) { DismApi.EnableFeatureByPackageName(GetDismSession(), package.PackageName, null, false, true); return(UpdateCacheAsync(GetCurrentFeatures())); }