I have the following code:
foreach (var process in Process.GetProcessesByName(name))
{
try
{
process.Kill();
if (!process.WaitForExit(timeout))
{
session.Log("Killing process {0} timed out.", name);
}
else
{
session.Log("Killing process {0} finished successfully.", name);
}
}
catch (Exception exception)
{
session.Log("Exception while trying to kill process {0}: {1}", name, exception.ToString());
}
}
Process.Kill throws the following exception:
Exception while trying to kill process <process name>: System.ComponentModel.Win32Exception (0x80004005): Access is denied
at System.Diagnostics.Process.Kill()
at CustomActions.CustomActions.KillAllProcesses(String name, Session session, Nullable`1 wait)
, , . , , , . Process.Kill . . , , . nuking , , - , ? IO , - , . ? P/Invoking TerminateProcess?