C#中如何使用Process.Start()使一個無gui的exe應用程序在後臺啓動

C#中如何使用Process.Start()使一個無gui的exe應用程序在後臺啓動

比如
在cmd模式下可以使用 start/b abc.exe -argument


//聲明一個程序信息類
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
//設置外部程序名
Info.FileName = "notepad.exe";
//設置隱藏窗口
Info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//設置外部程序的啓動參數(命令行參數)爲test.txt
Info.Arguments = "test.txt";
//設置外部程序工作目錄爲  C:/
Info.WorkingDirectory = "C://";
//聲明一個程序類
System.Diagnostics.Process Proc;
try
{
    //
    //啓動外部程序
    //
    Proc = System.Diagnostics.Process.Start(Info);
}
catch (System.ComponentModel.Win32Exception exc)
{
    Console.WriteLine("系統找不到指定的程序文件。/r{0}", exc);
    return;
} 
 ( ImageView_Fullscreen ) problem:

 

// First create a ProcessStartInfo object. 
// First parameter the rundll32.exe command. 
// Second parameter the shimgvw.dll command along with the file name. 
System.Diagnostics.ProcessStartInfo f = new 
System.Diagnostics.ProcessStartInfo 
("C://windows//system32//rundll32.exe"
"C://windows//system32//shimgvw.dll,ImageView_Fullscreen " + 
fileName.TrimEnd (null)); 
try 

// Pass the ProcessStartInfo object to the Start function. 
System.Diagnostics.Process.Start (f); 

catch (Exception ex) 

System.Diagnostics.Debug.WriteLine (ex.ToString ()); 
}

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章