Run Command Prompt Commands

前端 未结 14 1975
暖寄归人
暖寄归人 2020-11-21 05:32

Is there any way to run command prompt commands from within a C# application? If so how would I do the following:

copy /b Image1.jpg + Archive.rar Image2.jp         


        
14条回答
  •  面向向阳花
    2020-11-21 06:08

    var proc1 = new ProcessStartInfo();
    string anyCommand; 
    proc1.UseShellExecute = true;
    
    proc1.WorkingDirectory = @"C:\Windows\System32";
    
    proc1.FileName = @"C:\Windows\System32\cmd.exe";
    proc1.Verb = "runas";
    proc1.Arguments = "/c "+anyCommand;
    proc1.WindowStyle = ProcessWindowStyle.Hidden;
    Process.Start(proc1);
    

提交回复
热议问题