Processes are started alternately. But can not be executed tk. the previous one is not complete.

public static void RemoveProvisionedAppxPackage__Name() { string[] list_names = { "Microsoft.3DBuilder_11.0.47.0_neutral_~_8wekyb3d8bbwe", "Microsoft.BingWeather_4.9.51.0_neutral_~_8wekyb3d8bbwe" }; foreach (var i in list_names) { RemoveProvisionedAppxPackage__Name2(@"/Image:z:\_images\_mount /Remove-ProvisionedAppxPackage /PackageName:" + i); }; } public static void RemoveProvisionedAppxPackage__Name2(string name) { Process MyProc = new Process(); MyProc.StartInfo.FileName = @"Dism.exe"; MyProc.StartInfo.Arguments = name; MyProc.Start(); } 
  • Well, do not start the process until the old one is completed. What is the difficulty? - VladD
  • they are in foreach loop - codename0082016
  • @ codename0082016: Yes, so what? Wait until the end of the foreach . - VladD

1 answer 1

It helped ........

 MyProc.WaitForExit();