0

インストールしている別のアプリケーションの依存関係に対して dotnet 3.5 を有効にしようとしています。問題は、使用している cmd シェルがこのエラーをスローすることです。「'dism' は、内部または外部コマンド、操作可能なプログラムまたはバッチ ファイルとして認識されません。」しかし、cmd シェルに渡す文字列をコピーして貼り付けると、次のようになります。

Dism /online /LogPath:C:\Users\HollyPlyler\source\repos\installerOptimized\installerOptimized\bin\Debug\\Logs\DSIMEnableDotNet.log /LogLevel:4 /Enable-Feature /FeatureName:NetFx3

それは正常に動作します。

これが私のCMDクラスです:

 class CommandLineTool
    {
        public async Task Com(String command, string logName)
        {
            Console.WriteLine("received " + command);
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.UseShellExecute = false;
            startInfo.CreateNoWindow = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.UseShellExecute = false;
            startInfo.FileName = "CMD.exe";
            startInfo.Arguments = "/c " + command;
            process.StartInfo = startInfo;

            Task t = Task.Run(()=>process.Start());
            t.Wait();
            string output = process.StandardOutput.ReadToEnd();
            Console.BackgroundColor = ConsoleColor.Black;
            if (output.Contains("0/1"))
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                installerOptimized.install.success = false;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Green;
                installerOptimized.install.success = true;
            }
            Console.WriteLine(output);
            string success = installerOptimized.install.success ? "successful" : "unsuccessful";
            System.IO.File.WriteAllLines("Logs/" + logName +"_" + success + ".txt", output.Split('\n'));
            process.WaitForExit();
    }
}
4

1 に答える 1