Run CMD command without displaying it?

前端 未结 4 1039
难免孤独
难免孤独 2021-02-20 09:59

I have created a Process to run command in CMD.

var process = Process.Start(\"CMD.exe\", \"/c apktool d app.apk\");
process.WaitForExit();

How

4条回答
  •  深忆病人
    2021-02-20 10:46

    You can use the WindowsStyle-Property to indicate whether the process is started in a window that is maximized, minimized, normal (neither maximized nor minimized), or not visible

    process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
    

    Source: Property:MSDN Enumartion: MSDN

    And change your code to this, becaeuse you started the process when initializing the object, so the properties (who got set after starting the process) won't be recognized.

    Process proc = new Process();
    proc.StartInfo.FileName = "CMD.exe";
    proc.StartInfo.Arguments = "/c apktool d app.apk";
    proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    proc.Start();
    proc.WaitForExit();
    

提交回复
热议问题