2016-04-08 10 views
1

VB.NET/C#でDOSアプリケーションにシェルする方法はありますか?私はむしろそれが点滅するので表示されません、それは開いて、処理を終えて終了します。表示されていないプログラムにシェルリングする

+1

の可能性のある重複した[?プロセスウィンドウを非表示に、なぜそれが機能していない](http://stackoverflow.com/questions/23246613/hiding-the-process-window-why-isnt:以下に引用-it-working) – cokeman19

答えて

1

この情報は役に立ちました。example

static void LaunchCommandLineApp() 
{ 
    // For the example. 
    const string ex1 = "C:\\"; 
    const string ex2 = "C:\\Dir"; 

    // Use ProcessStartInfo class. 
    ProcessStartInfo startInfo = new ProcessStartInfo(); 
    startInfo.CreateNoWindow = false; 
    startInfo.UseShellExecute = false; 
    startInfo.FileName = "dcm2jpg.exe"; 
    startInfo.WindowStyle = ProcessWindowStyle.Hidden; 
    startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2; 

    try 
    { 
     // Start the process with the info we specified. 
     // Call WaitForExit and then the using-statement will close. 
     using (Process exeProcess = Process.Start(startInfo)) 
     { 
      exeProcess.WaitForExit(); 
     } 
    } 
    catch 
    { 
     // Log error? 
    } 
} 
+0

'startInfo.CreateNoWindow = false;は' true'にするべきではありませんか? – ChrFin

+0

同じことが 'ProcessWindowStyle.Hidden;'のように見えます。いくつかのアプリケーションは、ウィンドウがどこかに存在することを望んでいるかもしれません...私はそれらが動作するように正確な方法で動作するまで、これらの設定を操作することをお勧めします。私の答えは、プロセス設定にアクセスするための手段を提供することだけを意味していました。 –

+0

素晴らしいですが、WindowStyleが修正しました。物事が間違っているときにアプリを停止することはさらに困難です:)ありがとうございますMiscellaneousUser a.k.a.エージェント005 – MiscellaneousUser

関連する問題