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 GaradRank #191 · 12.8K reputationPosted Mar 9, 2011, 12:15 AM EST
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.
gavriel ankri36 reputationPosted Mar 9, 2011, 12:44 AM EST
Suthish NairRank #92 · 22.8K reputationPosted Mar 9, 2011, 12:48 AM EST
//startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
foreach (Process pr in Process.GetProcessesByName("wmplayer"))
pr.Kill();
Sam HobbsRank #107 · 20.5K reputationPosted Mar 9, 2011, 6:32 PM EST