This question has already been answered:

Command 1 is executed in powershell

Dism /online /Get-FeatureInfo /FeatureName:TFTP 

In the c # application, nothing is done, the console opens and nothing else happens:

 ProcStartargs("powershell", "-command \" Dism /online /Get-FeatureInfo /FeatureName:TFTP \""); public static void ProcStartargs(string name, string args) { try { var proc = new Process { StartInfo = new ProcessStartInfo { FileName = name, Arguments = args, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true, StandardOutputEncoding = Encoding.GetEncoding(866) } }; proc.Start(); // ReSharper disable once NotAccessedVariable string line = null; while (!proc.StandardOutput.EndOfStream) { line += Environment.NewLine + proc.StandardOutput.ReadLine(); } proc.WaitForExit(); } catch (Exception ex) { } } 

Team 2 doesn't work either

 ProcStartargs("powershell", "-command \" Dism /Mount-Image/ ImageFile:d:\\_images\\install.wim /Index:1 /mountdir:d:\\_images\\_test \""); 

Marked as a duplicate by the participants andreycha , Duck Learns to Hide , aleksandr barakin , Mirdin , Streletz 3 Sep '16 at 16:30 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    2 answers 2

    dism.exe is a separate program, not a powershell command. Why run it through powershell?

    • So ProcStartargs(@"Dism.exe", @"/Mount-Image/ ImageFile:d:\_images\install.wim /Index:1 /mountdir:z:\_images\_test2"); does not work ProcStartargs(@"Dism.exe", @"/Mount-Image/ ImageFile:d:\_images\install.wim /Index:1 /mountdir:z:\_images\_test2"); ProcStartargs(@"Dism.exe", @"/online /Get-FeatureInfo /FeatureName:TFTP"); - codename0082016
    • @ codename0082016 what does "not work" mean? - Pavel Mayorov
    • System.Diagnostics.Process MyProc = new System.Diagnostics.Process(); MyProc.StartInfo.FileName = @"c:\Windows\WinSxS\x86_microsoft-windows-d..ervicing-management_31bf3856ad364e35_10.0.14393.0_none_2fff730f6c019e77\Dism.exe"; MyProc.StartInfo.Verb = "/Get-Help"; MyProc.Start(); Unhandled exception of type "System.ComponentModel.Win32Exception" in System.dll Additional information: No application has been associated with the specified file for performing this operation - codename0082016
    • @ codename0082016 where did you get the verb? - Pavel Mayorov
    • typo there Arguments. Now error Error 87: The parameter is set incorrectly. System.Diagnostics.Process MyProc = new System.Diagnostics.Process(); MyProc.StartInfo.FileName = @"c:\Windows\WinSxS\x86_microsoft-windows-d..ervicing-management_31bf3856ad364e35_10.0.14393.0_none_2fff730f6c019e77\Dism.exe"; MyProc.StartInfo.Arguments = "/Get-Help"; MyProc.Start(); - codename0082016
     Process MyProc = new Process(); MyProc.StartInfo.FileName = @"Dism.exe"; MyProc.StartInfo.Arguments = @"/Mount-Image /ImageFile:d:\_images\install.wim /Index:1 /mountdir:d:\_images\_test2"; MyProc.Start();