Run command line code programmatically using C#

前端 未结 3 1827
野趣味
野趣味 2020-12-01 13:14

I\'m using this code run in windows command prompt.. But I need this done programmatically using C# code

C:\\Windows\\Microsoft.NET\\Framework\\v4.0.3

3条回答
  •  失恋的感觉
    2020-12-01 13:49

    try this

    ExecuteCommand("Your command here");
    

    call it using process

     public void ExecuteCommand(string Command)
        {
            ProcessStartInfo ProcessInfo;
            Process Process;
    
            ProcessInfo = new ProcessStartInfo("cmd.exe", "/K " + Command);
            ProcessInfo.CreateNoWindow = true;
            ProcessInfo.UseShellExecute = true;
    
            Process = Process.Start(ProcessInfo);
        }
    

提交回复
热议问题