Hi,
I need to Close / Kill the already opened Main Winform application through C# coding, and will sopport all the operatingg system (Win 7 32 & 64 bit, Vista 32 & 64 Bit etc).
I already tried the below code but some times it didn't work in XP.
And rest OS this is not working. Please find below code:
Process thisProc = null;
string processName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
foreach (Process openedProcesses in Process.GetProcesses())
{
if (openedProcesses.ProcessName.Contains(processName))
{
thisProc = openedProcesses;
thisProc.CloseMainWindow();
thisProc.Kill();
}
}
Thanks in Adavance.
Loading
VulpesPosted Oct 10, 2011, 5:13 AM
Prabhu RajaPosted Oct 10, 2011, 2:53 AM
Also Try this one. (untested)
thisProc = openedProcesses;
thisProc.CloseMainWindow();
thisProc.Dispose();
thisProc.Kill();
thisProc.Close();