hello. I am new in this forum and I hope you can help me.
I am trying to open an application, minimize it and then kill it when I click on a button.
I did it like this:
Process newProcess = Process.Start("wmplayer.exe");
newProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
and then kill it when i press a button:
if (newProcess != null)
newProcess.Kill();
everything ok except the Minimize. the application start in full windows and I dont know how to Minimize it.
If I do like this its work for me:
ProcessStartInfo newprocess = new ProcessStartInfo("wmplayer.exe");
newprocess.WindowStyle = ProcessWindowStyle.Minimized;
but then I cant kill the process.
I hope you can hep me
thank you
Loading
Krishna GaradPosted Mar 9, 2011, 5:15 AM
private void KillProcess()
{
Boolean isAlive = true;
while (isAlive == true)
{
foreach (Process runningProcess in System.Diagnostics.Process.GetProcesses())
{
if (runningProcess.ProcessName == "wmplayer.exe")
{
runningProcess.Kill();
}
else
{
isAlive = false;
}
}
}
}
Call this method where you want.
Sam HobbsPosted Mar 9, 2011, 11:32 PM
Suthish NairPosted Mar 9, 2011, 5:48 AM
//startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
foreach (Process pr in Process.GetProcessesByName("wmplayer"))
pr.Kill();
gavriel ankriPosted Mar 9, 2011, 5:44 AM